Part Number Hot Search : 
MC68185 74HC7 TLMH3102 SMBJ36A VHC1G0 2SC52 BC848 NF25T
Product Description
Full Text Search
 

To Download M30240S7-XXXFP Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  mitsubishi electronics america, inc. preliminary m30240 m30240 group speci?cation description. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 features...............................................................1-3 applications......................................................... 1-3 pin configuration ................................................ 1-4 block diagram..................................................... 1-5 performance outline............................................ 1-6 pin description.................................................... 1-8 overview ........................................................... 1-10 operation of functional blocks . . . . . . . . . 1-11 central processing unit (cpu) ......................... 1-11 processor mode................................................ 1-14 memory ............................................................. 1-15 sfr map .......................................................... 1-16 reset................................................................. 1-22 software reset ................................................. 1-23 clock-generating circuit................................... 1-23 clock control .................................................... 1-24 stop mode......................................................... 1-26 wait mode......................................................... 1-26 status transition of the internal clock f ......... 1-26 power control ................................................... 1-27 protection.......................................................... 1-28 interrupts........................................................... 1-29 nmi interrupt ..................................................... 1-35 key-input interrupt ............................................ 1-36 address match interrupt.................................... 1-38 watchdog timer................................................ 1-39 frequency synthesizer circuit .......................... 1-41 universal serial bus.......................................... 1-44 dmac ............................................................... 1-63 timers ............................................................... 1-68 timer a ............................................................. 1-69 timer b ............................................................. 1-80 uart0 through uart2 .................................... 1-83 a-d converter ................................................. 1-106 crc calculation circuit .................................. 1-116 programmable i/o ports ................................. 1-117 usage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-124 usage precautions.......................................... 1-124 specifications . . . . . . . . . . . . . . . . . . . . . . 1-128 electrical ......................................................... 1-128 timing ............................................................. 1-130 timing diagrams- peripheral/interrupt ............ 1-133 applications . . . . . . . . . . . . . . . . . . . . . . . 1-134 frequency synthesizer interface and dc-dc converter..................................... 1-134 attach/detach function................................... 1-138 low pass filter network ................................. 1-139 usb transceiver............................................. 1-140 programming notes ........................................ 1-141
mitsubishi electronics america, inc. 1-2
1-3 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change features 1.0 description the m30240 group is a 16-bit microcomputer based on the m16c family core technology. they are single-chip usb peripheral microcontrollers based on the universal serial bus (usb) version 1.1 specification. they are packaged in an 80-pin, molded plastic qfp. these single-chip microcontrollers operate using sophisticated instructions featuring a high level of instruction efficiency, making them capable of executing instructions at high speed. they also feature a built-in multiplier and dmac, making them ideal for controlling office communications, industrial equipment, and other high-speed processing applications. 1.1 features ? cpu .................................................... 16-bit (including a hardware multiplier) ? number of instructions ........................ 91 ? shortest instruction execution time ..... 83ns f(x in )=12mhz ? usb features:..................................... five endpoint pairs (in/out) fifo sizes (endpoints 0-4):32,128, 32, 32, 32 conforms to usb v1.1 speci?cation ? usb transceiver ................................. conforms to usb v1.1 speci?cation-internal vref ? frequency synthesizer........................ pll for 48mhz clock ? memory capacity (mask device):......... rom (40k, 48k) / ram (3.0 k) ? memory capacity (otp device):.......... prom (128k) / ram (5k) ? supply voltage .................................... 4.1 to 5.25v f(x in )=12mhz) ? interrupts............................................. 21 internal and 4 external interrupt sources, 4 software interrupt sources; 7 levels (including key input interrupt x 16) ? multifunction timer ............................... 5 x 16-bit, w/integrated 20ma (peak) pwm outputs ? general purpose timer ........................ 3 x 16-bit, internal interrupt only ? uart................................................... 3 x 7/8/9 bits; con?gurable for synchronous or asynchronous mode ? dmac.................................................. 2 channels (trigger: 18 sources) ? a-d converter ..................................... 10 bits x 8 channels ? crc calculation circuit ........................ 1 circuit (industry standard polynomial) ? watchdog timer ................................... 1 line (15 bit) ? programmable i/o............................... 63 lines ? high current and led drivers ............. 5 high current and 8 led drivers ? clock-generating circuit....................... 1 built-in circuit including feedback resistor ? package: ............................................. 80p6n (0.8 mm pitch) 1.2 applications usb peripherals, such as telephones, audio systems, scanners, and digital cameras.
1-4 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change pin configuration 1.3 pin con?guration figure 1.1 shows the pin configuration (top view). figure 1.1: pin con?guration (top view) 41 40 24 65 p100/an0 66 avss 67 lpf 68 vref 69 avcc 70 p87/ ad trg 71 p86/sof 72 extcap 73 74 75 76 77 78 79 80 23 22 21 20 19 18 17 16 15 p84/int1 14 p85/ nmi 13 vcc 12 11 10 xin 9 vss 8 xout 7 6 d- 5 d+ 4 3 2 1 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 p107/an7 p106/an6 p105/an5 m30240mx/ec reset 61 p104/an4 62 p103/an3 63 p102/an2 64 p101/an1 p83/attach p82/int0 p81/ta4in p80/ta4out p77/ta3in p75/ta2in p72/clk2/t a1out p73/ cts2/rts2 /ta1in p74/ta2out p76/ta3out p32 p33 p34 p35 p36 p37/clkout p60/cts0/rts0 p61/clk0 p62/rxd0 p63/txd0 p64/ cts1/rts1/clks1 p65/clk1 p66/rxd1 p67/txd1 p70/txd2/ta0out p71/rxd2/ta0in p03/ ki3 p02/ ki2 p01/ ki1 p00/ ki0 p04/ ki4 p05/ ki5 p06/ ki6 p07/ ki7 p10/ ki8 p11 /ki9 p12/ ki10 p13/ ki11 p14/ ki12 p15/ ki13 p16/ ki14 vss p17/ ki15 vcc p20/led0 p21/led1 p22/led2 p23/led3 p24/led4 p25/led5 p26/led6 p27/led7 p30 p31 byte cnvss
1-5 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change block diagram 1.4 block diagram figure 1.2 is a block diagram of the m30240 group. figure 1.2: block diagram of m30240 group timer timer ta0 (16 bits) timer ta1 (16 bits) timer ta2 (16 bits) timer ta3 (16 bits) timer ta4 (16 bits) timer tb0 (16 bits) timer tb1 (16 bits) timer tb2 (16 bits) internal peripheral functions watchdog timer (1 line) dmac (2 channels) a-d converter 10 bits x 8 channels uart/clock synchronous si/o (8 bits x 3 channels) (note 1) system clock generator x in -x out i/o ports crc arithmetic circuit (ccitt) (polynomial : x 16 +x 12 +x 5 +1) note 1: one of serial i/o can be used for sim interface. memory rom ram m16c series16-bit cpu core r0l r0h r0l r0h r1h r1l r2 r3 a0 a1 fb registers isp usp stack pointer vector table intb multiplier sb flg pc program counter port p0 8 port p1 8 port p2 8 port p3 8 port p6 8 port p7 8 port p8 0 ~8 4 8 6 , 8 7 7 port p8 5 port p10 8 usb function frequency synthesizer
1-6 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change performance outline 1.5 performance outline table 1.1 is a performance outline of the m30240 group. table 1.1: performance outline of m30240 group item performance number of basic instructions 91 instructions shortest instruction execution time 83ns (f(x in ) =12mhz) memory capacity rom (see figure 3: rom capacity ?eld) ram i/o port p0 to p3, p6,p7, p8 (except p85), p10 8 bits x 7, 7 bits x 1 input port p85 1 bit x 1 multifunction timer ta0, ta1, ta2, ta3, ta4 16 bits x 5 general purpose timer tb0, tb1, tb2 16 bits x 3 serial i/o uart0, uart1, uart2 (uart or clock synchronous) x 3 a-d converter 10 bits x 8 channels dmac 2 channels (trigger:18 sources) crc calculation circuit crc-ccitt watchdog timer 15 bits x 1 (with prescaler) interrupt 21 internal and 4 external sources, 4 software sources, 7 levels clock-generating circuit built-in clock generation circuit (built-in feedback resistor, and external ceramic or quartz oscillator) supply voltage (typical) 4.1 to 5.25v, (f(x in )=12mhz, without software wait) power consumption (typical) 250 mwatt, vcc=5.0v, 12mhz i/o characteristics i/o withstand voltage 5v average output current 5 ma available on ports p0, p1, p3,p6, p7 1 , p7 3 , p7 5 , p7 7 , p8 1 ~p8 4 , p8 6 , p8 7 , p10 10 ma available on ports p2, p7 0 , p7 2 , p7 4 , p7 6 , p8 0 operating temperature 0 to 70 o c device con?guration cmos high performance silicon gate package 80-pin plastic molded qfp
1-7 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change performance outline mitsubishi plans to release the following products in the m30240 group: (1) support for mask rom version and one-time prom version (2) rom capacity (3) package ? 80p6n: plastic molded qfp (mask rom version and one-time prom version) figure 1.3 shows the type number, memory size and package for the m30240 group. figure 1.3: type number, memory size, and package table 1.2 shows the package number, type, rom and ram capacity for m30240 group. table 1.2: m30240 group type rom capacity ram capacity package type remarks m30240m5 40k bytes 3k bytes 80p6n mask rom version m30240m6 48k bytes 3k bytes 80p6n mask rom version m30240ecfp 128k bytes 5k bytes 80p6n one-time prom version package type: fp : package 80p6n rom no. omitted for blank one-time prom version,and eprom version rom capacity: 1: 8k bytes 7: 56k bytes 2: 16k bytes 8: 64k bytes 3: 24k bytes 9: 80k bytes 4: 32k bytes a: 96k bytes 5: 40k bytes c: 128k bytes 6: 48k bytes memory type: m : mask rom version e : eprom or one-time prom version s : external rom version f : flash memory version type no. m 3 0 24 0 m 5 C x x x f p m30240 group m16c family part type: specifies part variations with m30240 group
1-8 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change pin description 1.6 pin description table 1.3: figure pin description pin # name i/o description 1 p8 7 i/o cmos i/o port. this pin also functions as an external trigger for a-d conversion. 2 p8 6 i/o cmos i/o port. this pin also functions as the start of frame (sof) pulse for the usb module. 3 p8 5 / (nmi) i cmos input port. this pin also functions as a non-maskable external interrupt. 4,5 p8 4 ~ p8 3 i/o cmos i/o port. these pins also functions as external interrupt 1 and are used to enable the stealth detach function for the usb transceiver. 6 extcap _ an external capacitor (ext. cap) pin. when the usb transceiver voltage converter is used, a 2.2 m f and a 0.1 m f capacitor should connect between this pin and v ss to ensure proper operation of the usb line driver. this option is enabled by setting bit 4 of the usb control register (000c 16 ) to a 1. 7 byte i connect this pin to vss 8 cnv ss i connect this pin to vss 9 usb d + i/o usb d+ voltage line interface, a series resistor of 33 w is connected to this pin. 10 usb d - i/o usb d- voltage line interface, a series resistor of 33 w is connected to this pin. 11 reset i a l on this input resets the microcomputer. 12 xout o see xin 13 v ss i ground: v ss = 0v 14 xin i input and output signals to and from the internal clock generation circuit. connect a ceramic resonator or quartz crystal between xin and xout pins to set the oscillation frequency. if an external clock is used, connect the clock source to the xin pin and leave the xout pin open. 15 v cc i power: v cc = 4.1~ 5.25v 16 p8 2 i/o cmos i/o port. this pin also functions as external interrupt 0. 17-18 p8 1 ~ p8 0 i/o cmos i/o port. pins in this port also function as timera4 input and output as selected by software. 19-22 p7 7 ~ p7 4 i/o cmos i/o port. pins in this port also function as timer pins. p7 7 and p7 6 can function as timera3 input and output as selected by software. p7 5 and p7 4 can function as timera2 input and output as selected by software. 23-26 p7 3 ~ p7 0 i/o cmos i/o port. pins in this port also function as uart2 cts, rts, clk, rxd, and txd as selected by software. p7 3 and p7 2 can function as timera1 input and output as selected by software. p7 1 and p7 0 can function as timera0 input and output as selected by software. 27-30 p6 7 ~ p6 4 i/o cmos i/o port. pins in this port also function as uart1 cts, rts, clk, serial clock, rxd, and txd as selected by software. txd(oe~) and rts(suspend) in addition to d+ and d- can be used to run the device in usb bypass mode. 31-34 p6 3 ~ p6 0 i/o cmos i/o port. pins in this port also function as uart0 cts, rts, clk, rxd, and txd as selected by software. 35-42 p3 7 ~ p3 0 i/o cmos i/o port. 43-50 p2 7 /led7 ~ p2 0 /led0 i/o cmos i/o port. these pins are capable of driving up to 20ma (peak) for leds.
1-9 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change pin description 51 v cc i power: v cc = 4.1~ 5.25v 52 p1 7 / ki 15 i/o cmos i/o port. this port can also function as the key-on wakeup interrupt ki15. 53 v ss i ground: v ss = 0v 54-60 p1 6 / ki 14 ~ p1 0 / ki 8 i/o cmos i/o port. this port can also function as the key-on wakeup interrupts ( ki8 ~ ki14). 61-68 p0 7 / ki 7 ~ p0 0 / ki 0 i/o cmos i/o port. this port can also function as the key-on wakeup interrupts ( ki0 ~ ki7). 69-76 p10 7 ~ p10 0 i/o cmos i/o port. these pins also function as analog inputs 7-0 for a-d conversion 77 av ss i this pin is a power supply input for the ad converter. (connect to vss) 78 lpf o loop ?lter for the frequency synthesizer. 79 v ref i this pin is the reference voltage input for the a-d converter. 80 av cc i this pin is a power supply input for the ad converter. (connect to vcc) table 1.3: figure pin description pin # name i/o description
1-10 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change overview 1.7 overview the m30240 group is a single chip pc peripheral microcontroller based on the universal serial bus (usb) version 1.1 specification. this device provides interface between a usb- equipped host computer and pc peripherals such as telephones, audio systems, and digital cameras. the m30240 block diagram is shown in figure 1.4. the usb function control unit of the m30240 group can support all four data transfer types listed in the usb specification: isochronous, interrupt, bulk, and control. each transfer type is used for controlling a different set of pc peripherals. isochronous transfers provide guaranteed bus access, a constant data rate, and error tolerance for devices such as computer-telephone integration (cti) and audio systems. interrupt transfers are designed to support human input devices (hid) that communicate small amounts of data infrequently. bulk transfers are necessary for devices such as digital cameras and scanners that communicate large amounts of data to the pc as bus bandwidth becomes free. finally, control transfers are supported and are useful for bursty, host-initiated type communication where bus management is the primary concern. figure 1.4: m30240 block diagram frequency ram dmac x 2 m16c cpu uart x 3 timers x 8 watchdog crc circuit i/o ports (p0~p3, p6 ~ p8, p10) fifos usb function control unit transceiver d+ d- (normal mcu or dma transfer) 1 - 12mhz 48 mhz f synthesizer led drivers (x 8) a-d converter timer rom
1-11 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change central processing unit (cpu) 2.0 operation of functional blocks the m30240 group accommodates certain units in a single chip. these units include rom and ram to store instructions and data, and the central processing unit (cpu) to execute arithmetic/logic operations. also included are peripheral units such as usb, timers, serial i/o, dmac, crc calculation circuit, a-d converter, and i/o ports. the following explains each unit. 2.1 central processing unit (cpu) the cpu has a total of 13 registers shown in figure 1.5. seven of these registers (r0, r1, r2, r3, a0, a1, and fb) come in two sets; therefore, these have two register banks. figure 1.5: central processing unit register 2.1.1 data registers (r0, r0h, r0l, r1, r1h, r1l, r2, and r3) data registers (r0, r1, r2, and r3) are configured with 16 bits, and are used primarily for transfer and arithmetic/logic operations. aaaaaaa aaaaaaa h l b15 b8 b7 b0 r0 (note) aaaaaaa aaaaaaa h l b15 b8 b7 b0 r1 (note) r2 (note) aaaaaaa b15 b0 r3 (note) aaaaaaa aaaaaaa b15 b0 a0 (note) aaaaaaa aaaaaaa b15 b0 a1 (note) aaaaaaa b15 b0 fb (note) aaaaaaa aaaaaaa b15 b0 data registers address registers frame base registers b15 b0 b15 b0 b15 b0 b15 b0 b0 b19 b0 b19 h l program counter interrupt table register user stack pointer interrupt stack pointer static base register flag register pc intb usp isp sb flg note: these registers consist of two register banks. aa aa aa aa a a aa aa aaaaaa aaaaaa aa aa aa aa a a aa aa aa aa c d z s b o i u ipl
1-12 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change central processing unit (cpu) registers r0 and r1 each can be used as separate 8-bit data registers, high-order bits as (r0h/r1h), and low-order bits as (r0l/r1l). in some instructions, registers r2 and r0, as well as r3 and r1, can be used as 32-bit data registers (r2r0/r3r1). 2.1.2 address registers (a0 and a1) address registers (a0 and a1) are configured with 16 bits, and have functions equivalent to those of data registers. these registers can also be used for address register indirect addressing and address register relative addressing. in some instructions, registers a1 and a0 can be combined for use as a 32-bit address register (a1a0). 2.1.3 frame base register (fb) frame base register (fb) is configured with 16 bits, and is used for fb relative addressing. 2.1.4 program counter (pc) program counter (pc) is configured with 20 bits, indicating the address of an instruction to be execut- ed. 2.1.5 interrupt table register (intb) interrupt table register (intb) is configured with 20 bits, indicating the start address of an interrupt vec- tor table. intb can be used as separate registers of four high-order bits and 16 low-order bits. 2.1.6 stack pointer (usp/isp) stack pointer comes in two types: user stack pointer (usp) and interrupt stack pointer (isp), each con- figured with 16 bits. your desired type of stack pointer (usp or isp) can be selected by a stack pointer select flag (u flag). this flag is located at the position of bit 7 in the flag register (flg). 2.1.7 static base register (sb) static base register (sb) is configured with 16 bits, and is used for sb relative addressing. 2.1.8 flag register (flg) flag register (flg) is configured with 11 bits, each bit is used as a flag. figure 1.6 shows the flag reg- ister (flg). the following explains the function of each flag: 2.1.8.1 bit 0: carry flag (c flag) this flag retains a carry, borrow, or shift-out bit that has occurred in the arithmetic/logic unit. 2.1.8.2 bit 1: debug flag (d flag) this flag enables a single-step interrupt. when this flag is 1, a single-step interrupt is generated after instruction execution. this flag is cleared to 0 when the interrupt is acknowledged. 2.1.8.3 bit 2: zero flag (z flag) this flag is set to 1 when an arithmetic operation resulted in 0; otherwise, cleared to 0. 2.1.8.4 bit 3: sign flag (s flag) this flag is set to 1 when an arithmetic operation resulted in a negative value; otherwise, cleared to 0. 2.1.8.5 bit 4: register bank select flag (b flag) this flag chooses a register bank. register bank 0 is selected when this flag is 0; register bank 1 is selected when this flag is 1. 2.1.8.6 bit 5: overflow flag (o flag) this flag is set to 1 when an arithmetic operation resulted in overflow; otherwise, cleared to 0.
1-13 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change central processing unit (cpu) 2.1.8.7 bit 6: interrupt enable flag (i flag) this flag enables a maskable interrupt. an interrupt is disabled when this flag is 0, and is enabled when this flag is 1. this flag is cleared to 0 when the interrupt is acknowledged. 2.1.8.8 bit 7: stack pointer select flag (u flag) interrupt stack pointer (isp) is selected when this flag is 0; user stack pointer (usp) is selected when this flag is 1. this flag is cleared to 0 when a hardware interrupt is acknowledged or an int instruction of software inter- rupts 0 to 31 is executed. 2.1.8.9 bits 8 to 11: reserved area 2.1.8.10 bits 12 to 14: processor interrupt priority level (ipl) processor interrupt priority level (ipl) is configured with three bits, for specification of up to eight processor interrupt priority levels from level 0 to level 7. if a requested interrupt has priority greater than the processor interrupt priority level (ipl), the interrupt is en- abled. 2.1.8.11 bit 15: reserved area the c, z, s, and o flags are changed when instructions are executed. see the m16c software manual for details. figure 1.6: flag register (flg) carry flag debug flag zero flag sign flag register bank select flag overflow flag interrupt enable flag stack pointer select flag reserved area processor interrupt priority level reserved area flag register (flg) aa aa aa aa aa aa a a aaaaaaa aaaaaaa aa aa a a aa aa aa aa aa aa c d z s b o i u ipl b0 b15
1-14 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change processor mode 2.2 processor mode figure 1.7 shows the processor mode registers 0 and 1. figure 1.7: processor mode registers 0 and 1 processor mode register 0 (note 1) symbol address when reset pm0 0004 16 00 16 (note) bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 reserved bit note : set bit 1 of the protect register (address 000a 16 ) to 1 when writing new values to this register. processor mode register 1 (note) symbol address when reset pm1 0005 16 00xxxxx0 2 bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 nothing is assigned. these bits can neither be set nor reset. when read, their contents are indeterminate. reserved bit must always be set to 0 0 note : set bit 1 of the protect register (address 000a 16 ) to 1 when writing new values to this register. pm17 wait bit 0 : no wait state 1 : wait state inserted 0 must always be set to "0" pm03 software reset bit the device is reset when this bit is set to 1. the value of this bit is 0 when read. nothing is assigned. these bits can neither be set nor reset. when read, their contents are indeterminate. 0 0 0 0 0 0
1-15 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change memory 2.3 memory figure 1.8: memory map figure 1.8 is a memory map of the m30240 group. the address space extends the 1m bytes from address 00000 16 to fffff 16 . addresses above yyyyy 16 are rom. for example, in the m30240ecfp, there is 128k bytes of internal rom from e0000 16 to fffff 16 . the special page vector table is mapped from ffe00 16 to fffdb 16 . if the starting addresses of subroutines or the destination addresses of jumps are stored here, subroutine call instructions and jump instructions can be used as two-byte instructions, reducing the number of program steps. the vector table for fixed interrupts such as the reset and nmi are mapped from fffdc 16 to fffff 16 . the starting addresses of the interrupt routines are stored here. the address of the vector table for software interrupts can be set as desired using the internal register (intb). see section 2.12 on interrupts for further details. addresses below xxxxx 16 are ram. for example, in m30240ecfp, 5k bytes of internal ram are mapped to the space from 00400 16 to 017ff 16 . in addition to storing data, the ram also stores the stack used when calling subroutines and when interrupts are generated.the sfr area is mapped to 00000 16 to 003ff 16 . this area accommodates control registers for peripheral devices such as i/o ports, a-d converter, serial i/o, and timers. section 2.4 describes the sfr area for peripheral unit control registers. any part of the sfr area that is unoccupied is reserved and cannot be used for other purposes. yyyyy 16 overflow brk instruction address match single step watchdog timer reset 00000 16 00400 16 xxxxx 16 rom unused sfr ram ffe00 16 fffdc 16 fffff 16 undefined instruction special page vector table dbc nmi type address xxxxx 16 address yyyyy 16 m30240m5 01000 16 f6000 16 m30240m6 01000 16 f4000 16 m30240ecfp 01800 16 e0000 16
1-16 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change sfr map 2.4 sfr map the table below shows the peripheral control registers, their addresses, names, acronyms, and values after reset. address register name acronym value after reset 0000 16 0001 16 0002 16 0003 16 0004 16 processor mode register 0 pm0 00 16 0005 16 processor mode register 1 pm1 0 0 0 0006 16 system clock control register 0 cm0 48 16 0007 16 system clock control register 1 cm1 20 16 0008 16 0009 16 address match interrupt enable register aier 00 000a 16 protect register prcr 000 000b 16 000c 16 usb control register usbc 00 16 000d 16 000e 16 watchdog timer start register wdts 000f 16 watchdog timer control register wdc 0 0 0 ? ? ? ? ? 0010 16 address match interrupt register 0 rmad0 00 16 0011 16 00 16 0012 16 0000 0013 16 0014 16 address match interrupt register 1 rmad1 00 16 0015 16 00 16 0016 16 0000 0017 16 0018 16 0019 16 001a 16 001b 16 001c 16 001d 16 001e 16 reserved 001f 16 usb attach / detach register usbad 00 16 0020 16 dma0 source pointer sar0 0021 16 0022 16 0023 16 0024 16 dma0 destination pointer dar0 0025 16 0026 16 0027 16 0028 16 dma0 transfer counter tcr0 0029 16 002a 16 002b 16 002c 16 dma0 control register dm0con 0 0 0 0 0 ? 0 0 002d 16 002e 16 002f 16 0030 16 dma1 source pointer sar1 0031 16 0032 16 0033 16 0034 16 dma1 destination pointer dar1 0035 16 0036 16 0037 16 0038 16 dma1 transfer counter tcr1 0039 16 003a 16 003b 16 003c 16 dma1 control register dm1con 0 0 0 0 0 ? 0 0 003d 16 003e 16 003f 16
1-17 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change sfr map 0040 16 0041 16 0042 16 0043 16 0044 16 suspend interrupt control register suspic ?000 0045 16 0046 16 resume interrupt control register rsmic ?000 0047 16 usb sof interrupt control register sofic 00?000 0048 16 0049 16 004a 16 bus collision detection interrupt control register bcnic ?000 004b 16 dma0 interrupt control register dm0ic ?000 004c 16 dma1 interrupt control register dm1ic ?000 004d 16 key input interrupt control register kupic ?000 004e 16 a-d conversion interrupt control register adic ?000 004f 16 uart2 transmit interrupt control register s2tic ?000 0050 16 uart2 receive interrupt control register s2ric ?000 0051 16 uart0 transmit interrupt control register s0tic ?000 0052 16 uart0 receive interrupt control register s0ric ?000 0053 16 uart1 transmit interrupt control register s1tic ?000 0054 16 uart1 receive interrupt control register s1ric ?000 0055 16 timer a0 interrupt control register ta0ic ?000 0056 16 timer a1 interrupt control register ta1ic ?000 0057 16 timer a2 interrupt control register ta2ic ?000 0058 16 timer a3 interrupt control register ta3ic ?000 0059 16 timer a4 interrupt control register ta4ic ?000 005a 16 timer b0 interrupt control register tb0ic ?000 005b 16 timer b1 interrupt control register tb1ic ?000 005c 16 reset interrupt control register rstic ?000 005d 16 int0 interrupt control register int0ic 00?000 005e 16 int1 interrupt control register int1ic 00?000 005f 16 usb function interrupt control register usbfic ?000 - - - 0300 16 usb address register usba 00 16 0301 16 usb power management register usbpm 00 16 0302 16 usb interrupt status register 1 usbis1 00 16 0303 16 usb interrupt status register 2 usbis2 00 16 0304 16 usb interrupt enable register 1 usbie1 ff 16 0305 16 usb interrupt enable register 2 usbie2 33 16 0306 16 usb frame number register low usbsofl 00 16 0307 16 usb frame number register high usbsofh 00 16 0308 16 usb iso control register usbisoc 00 16 0309 16 usb dma0 source register usbsar0 00 16 030a 16 usb dma1 source register usbsar1 00 16 030b 16 usb endpoint enable usbepen ff 16 030c 16 030d 16 030e 16 030f 16 0310 16 usb reserved 0311 16 usb ep 0 control/status register ep0cs 00 16 0312 16 usb reserved 0313 16 usb ep 0 max packet size register ep0mp 08 16 0314 16 usb reserved 0315 16 usb ep 0 out write count ep0wc 00 16 0316 16 usb reserved 0317 16 usb reserved 0318 16 usb reserved 0319 16 usb ep 1 in control/status register ep1ics 00 16 031a 16 usb ep 1 out control/status register ep1ocs 00 16 031b 16 usb ep 1 in max packet size register ep1imp 00 16 031c 16 usb ep 1 out max packet size register ep1omp 00 16 031d 16 usb ep 1 out write count ep1wc 00 16 031e 16 usb reserved 031f 16 usb reserved address register name acronym value after reset
1-18 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change sfr map 0320 16 usb reserved 0321 16 usb ep 2 in control/status register ep2ics 00 16 0322 16 usb ep 2 out control/status register ep2ocs 00 16 0323 16 usb ep 2 in max packet size register ep2imp 00 16 0324 16 usb ep 2 out max packet size register ep2omp 00 16 0325 16 usb ep 2 out write count ep2wc 00 16 0326 16 usb reserved 0327 16 usb reserved 0328 16 usb reserved 0329 16 usb ep 3 in control/status register ep3ics 00 16 032a 16 usb ep 3 out control/status register ep3ocs 00 16 032b 16 usb ep 3 in max packet size register ep3imp 00 16 032c 16 usb ep 3 out max packet size register ep3omp 00 16 032d 16 usb ep 3 out write count ep3wc 00 16 032e 16 usb reserved 00 16 032f 16 usb reserved 0330 16 usb reserved 0331 16 usb ep 4 in control/status register ep4ics 00 16 0332 16 usb ep 4 out control/status register ep4ocs 00 16 0333 16 usb ep 4 in max packet size register ep4imp 00 16 0334 16 usb ep 4 out max packet size register ep4omp 00 16 0335 16 usb ep 4 out write count ep4wc 00 16 0336 16 usb reserved 0337 16 usb reserved 0338 16 usb ep 0 fifo ep0 0339 16 usb ep 1 fifo ep1 033a 16 usb ep 2 fifo ep2 033b 16 usb ep 3 fifo ep3 033c 16 usb ep 4 fifo ep4 033d 16 reserved 033e 16 reserved 033f 16 reserved 0340 16 0341 16 0342 16 0343 16 0344 16 0345 16 0346 16 0347 16 0348 16 0349 16 034a 16 034b 16 034c 16 034d 16 034e 16 034f 16 0350 16 0351 16 0352 16 0353 16 0354 16 0355 16 0356 16 0357 16 0358 16 0359 16 035a 16 035b 16 035c 16 035d 16 035e 16 035f 16 address register name acronym value after reset
1-19 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change sfr map 0370 16 0371 16 0372 16 0373 16 0374 16 0375 16 0376 16 0377 16 reserved 0378 16 uart2 transmit / receive mode register u2mr 00 16 0379 16 uart2 bit rate generator u2brg 037a 16 uart2 transmit buffer register u2tb 037b 16 037c 16 uart2 transmit /receive control register 0 u2c0 08 16 037d 16 uart2 transmit / receive control register 1 u2c1 02 16 037e 16 uart2 receive buffer register u2rb 037f 16 0380 16 count start ?ag tabsr 00 16 0381 16 reserved 0382 16 one-shot start ?ag onsf 0 0 00000 0383 16 trigger select register trgsr 00 16 0384 16 up-down ?ag udf 00 16 0385 16 0386 16 timer a0 ta0 0387 16 0388 16 timer a1 ta1 0389 16 038a 16 timer a2 ta2 038b 16 038c 16 timer a3 ta3 038d 16 038e 16 timer a4 ta4 038f 16 0390 16 timer b0 tb0 0391 16 0392 16 timer b1 tb1 0393 16 0394 16 timer b2 tb2 0395 16 0396 16 timer a0 mode register ta0mr 00 16 0397 16 timer a1 mode register ta1mr 00 16 0398 16 timer a2 mode register ta2mr 00 16 0399 16 timer a3 mode register ta3mr 00 16 039a 16 timer a4 mode register ta4mr 00 16 039b 16 timer b0 mode register tb0mr 0 0 ? 0000 039c 16 timer b1 mode register tb1mr 0 0 ? 0000 039d 16 timer b2 mode register tb2mr 0 0 ? 0000 039e 16 039f 16 03a0 16 uart0 transmit / receive mode register u0mr 00 16 03a1 16 uart0 bit rate generator u0brg 03a2 16 uart0 transmit buffer register u0tb 03a3 16 03a4 16 uart0 transmit / receive control register 0 u0c0 08 16 03a5 16 uart0 transmit / receive control register 1 u0c1 02 16 03a6 16 uart0 receive buffer register u0rb 03a7 16 03a8 16 uart1 transmit / receive mode register u1mr 00 16 03a9 16 uart1 bit rate generator u1brg 03aa 16 uart1 transmit buffer register u1tb 03ab 16 03ac 16 uart1 transmit / receive control register 0 u1c0 08 16 03ad 16 uart1 transmit / receive control register 1 u1c1 02 16 03ae 16 uart1 receive buffer register u1rb 03af 16 address register name acronym value after reset
1-20 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change sfr map 03b0 16 uart transmit / receive control register 2 ucon 0000000 03b1 16 03b2 16 03b3 16 03b4 16 03b5 16 03b6 16 03b7 16 03b8 16 dma0 cause select register dm0sl 00 16 03b9 16 03ba 16 dma1 cause select register dm1sl 00 16 03bb 16 03bc 16 crc data register crcd 03bd 16 03be 16 crc input register crcin 03bf 16 03c0 16 a-d register 0 ad0 03c1 16 03c2 16 a-d register 1 ad1 03c3 16 03c4 16 a-d register 2 ad2 03c5 16 03c6 16 a-d register 3 ad3 03c7 16 03c8 16 a-d register 4 ad4 03c9 16 03ca 16 a-d register 5 ad5 03cb 16 03cc 16 a-d register 6 ad6 03cd 16 03ce 16 a-d register 7 ad7 03cf 16 03d0 16 03d1 16 03d2 16 03d3 16 03d4 16 a-d control register 2 adcon2 0 03d5 16 03d6 16 a-d control register 0 adcon0 0 0 0 0 0 ? ? ? 03d7 16 a-d control register 1 adcon1 00 16 03d8 16 03d9 16 03da 16 03db 16 frequency synthesizer clock control fsccr 00 16 03dc 16 frequency synthesizer control fsc 60 16 03dd 16 frequency synthesizer multiplier control fsm ff 16 03de 16 frequency synthesizer prescaler control fsp ff 16 03df 16 frequency synthesizer divider fsd ff 16 03e0 16 port p0 p0 03e1 16 port p1 p1 03e2 16 port p0 direction register pd0 00 16 03e3 16 port p1 direction register pd1 00 16 03e4 16 port p2 p2 03e5 16 port p3 p3 03e6 16 port p2 direction register pd2 00 16 03e7 16 port p3 direction register pd3 00 16 03e8 16 03e9 16 03ea 16 03eb 16 03ec 16 port p6 p6 03ed 16 port p7 p7 03ee 16 port p6 direction register pd6 00 16 03ef 16 port p7 direction register pd7 00 16 address register name acronym value after reset
1-21 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change sfr map 03f0 16 port p8 p8 03f1 16 03f2 16 port p8 direction register pd8 0 0 00000 03f3 16 03f4 16 port p10 p10 03f5 16 03f6 16 port p10 direction register pd10 00 16 03f7 16 03f8 16 03f9 16 03fa 16 p2 drive capacity p2dr 00 16 03fb 16 timer a output drive capacity tadr 00 16 03fc 16 pull-up control register 0 pur0 00 16 03fd 16 pull-up control register 1 pur1 00 16 03fe 16 03ff 16 address register name acronym value after reset
1-22 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change reset 2.5 reset there are two types of resets: hardware and software. in both cases, operation is the same after the reset. (see software reset for further details regarding software resets.) this section explains on hardware resets. when the supply voltage is within the range where operation is guaranteed, a reset is effected by holding the reset pin level l (0.2vcc max.) for at least 20 f(x in ) cycles. when the reset pin level is then returned to the h level while main clock is stable, the reset status is cancelled and program execution resumes from the address in the reset vector table. figure 1.9 shows an example of a reset circuit. figure 1.10 shows the reset sequence. . figure 1.9: reset circuit figure 1.10: reset sequence reset v cc 0.8v reset v cc 0v 0v 5v 5v 4.0v example when v cc = 5v . address content of reset vector internal clock f 24 cycles ffffe 16 x in reset ffffc 16 at least 20 cycles are needed internal clock f
1-23 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change software reset when the reset pin level = l, all ports change to input mode (floating.) table 1.4 shows the status of the other pins while the reset pin level is l. table 1.4: main clock-generating circuits 2.6 software reset writing a 1 to bit 3 of the processor mode register 0 (address 0004 16 ) applies a (software) reset to the microcomputer. a software reset has almost the same effect as a hardware reset with the following exceptions: ? the contents of internal ram are preserved ? all usb, dc-dc converter, and pll sfr values are preserved. (see section 2.4) 2.7 clock-generating circuit the clock-generating circuit contains one oscillator circuit that supplies the operating clock sources to the cpu and internal peripheral units.example of oscillator circuit figure 1.11 shows some examples of the main clock circuit, one using an oscillator connected to the circuit, and the other one using an externally derived clock for input. circuit constants in figure 1.11 vary with each oscillator used. use circuit constant values recommended by the oscillator manufacturer. figure 1.11: examples of clock source functions main clock-generating circuit use of clock ? cpus operating clock source ? internal peripheral units operating clock source usable oscillator ceramic or crystal oscillator pins to connect oscillator xin , xout oscillation stop/restart function available oscillator status immediately after reset oscillating microcomputer (built-in feedback resistor) x in x out externally derived clock open vcc vss microcomputer (built-in feedback resistor) x in x out r d c in c out (note) note: insert a damping resistor if required. the resistance will vary depending on the oscillator and the oscillation drive capacity setting. use the value recommended by the maker of the oscillator. when the oscillation drive capacity is set to low, check that oscillation is stable.
1-24 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change clock control 2.8 clock control figure 1.12 shows the block diagram of the clock-generating circuit. figure 1.12: clock-generating circuit the following paragraphs describe the clocks generated by the clock-generating circuit. 2.8.1 main clock the main clock is generated by the main clock oscillation circuit. after a reset, the clock is divided by 8 to the internal clock f . the clock can be stopped using the main clock stop bit (bit 5 at address 0006 16 ). stopping the clock reduces the power dissipation. after the oscillation of the main clock oscillation circuit has stabilized, the drive capacity of the f(xout) pin can be reduced using the f(xin)-f(xout) drive capacity select bit (bit 5 at address 0007 16 ). reducing the drive capacity of the f(xout) pin reduces the power dissipation. this bit defaults to 1 when shifting to stop mode and after a reset. 2.8.2 internal clock f the internal clock f is the clock that drives the cpu, and is either the main clock or is derived by di- viding the main clock by 2, 4, 8, or 16. the internal clock f is derived by dividing the main clock by 8 after a reset. when shifting to stop mode, the main clock division select bit (bit 6 at 0006 16 ) is set to 1. cm0i : bit i at address 0006 16 cm1i : bit i at address 0007 16 fsccri: bit i at address 03db 16 wait instruction cm02 q s r nmi interrupt request level judgment output reset software reset f ad divider a d 1/2 1/2 1/2 1/2 cm06=0 cm17,cm16=00 cm06=0 cm17,cm16=01 cm06=0 cm17,cm16=10 cm06=1 cm06=0 cm17,cm16=11 d a details of divider c b b 1/2 c f 1 f 32 sio2 f 8 sio2 f 1 sio2 f 8 f 32 f x out main clock cm10 1 write signal q s r x in frequency synthesizer circuit f usb (48mhz) fsccr0=1 fsccr0=0 internal clock f fsyn
1-25 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change clock control 2.8.3 peripheral function clock 2.8.3.1 ? f1, f8, f32 the clock for the peripheral devices is derived from the main clock or by dividing it by 8 or 32. the peripheral function clock is stopped by stopping the main clock or by setting the wait peripheral func- tion clock stop bit (bit 2 at 0006 16 ) to 1 and then executing a wait instruction. 2.8.3.2 ? fad this clock has the same frequency as the main clock and is used for a-d conversion. 2.8.4 clock output in single-chip mode, the clock output function select bits (bits 0 and 1 at address 0006 16 ) enable f8 or f32 to be output from the p37/clkout pin. when the wait peripheral function clock stop bit (bit 2 at address 0006 16 ) is set to 1, the output of f8 and f32 stops when a wait instruction is executed. figure 1.13 shows the system clock control registers 0 and 1. figure 1.13: system clock control registers 0 and 1 note 1: set bit 0 of the protect register (address 000a 16 ) to 1 before writing to this register. note 2: changes to 1 when shifting to stop mode. note 3: can be selected when bit 6 of system clock control register 0 (address 0006 16 ) is 0. if 1, division mode if ?xed at 8. system clock control register 0 (note 1) note 1: set bit 0 of the protect register (address 000a 16 ) to 1 before writing to this register. note 2: changes to 1 when shifting to stop mode. system clock control register 1 (note 1) symbol address when reset cm1 0007 16 20 16 bit name function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 cm10 all clock stop control bit 0 : clock on 1 : all clocks off (stop mode) cm15 x in -x out drive capacity select bit (note 2) 0 : low 1 : high w r cm16 cm17 reserved bit always set to 0 reserved bit always set to 0 main clock division select bit 1 (note 3) 0 0 : no division mode 0 1 : division by 2 mode 1 0 : division by 4 mode 1 1 : division by 16 mode b7 b6 0 0 reserved bit always set to 0 reserved bit always set to 0 0 0 symbol address when reset cm0 0006 16 48 16 bit name function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 0 0 : i/o port p3 7 0 1 : invalid 1 0 : f 8 output 1 1 : f 32 output b1 b0 cm01 cm02 cm00 clock output function select bit wait peripheral function clock stop bit 0 : do not stop f 1 , f 8 , f 32 in wait mode 1 : stop f 1 , f 8 , f 32 in wait mode w r cm06 main clock division select bit 0 (note 2) 0 : cm16 and cm17 valid 1 : division by 8 mode reserved bit always set to "1" reserved bit always set to "0" reserved bit always set to "0" reserved bit always set to "0"
1-26 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change stop mode 2.9 stop mode writing 1 to the all-clock stop control bit (bit 0 at address 0007 16 ) stops all oscillation and the microcomputer enters stop mode. in stop mode, the content of the internal ram is retained provided that vcc remains above 2v. because the oscillation of internal clock f , f1 to f32, and fad stops in stop mode, peripheral functions such as the a-d converter and watchdog timer do not function. however, timer a operates, provided that the event counter mode is set to an external pulse, and uarti (i = 0 to 2) functions provided an external clock is selected. table 1.5 shows the status of the ports in stop mode. stop mode is cancelled by a hardware reset or interrupt. if an interrupt is to be used to cancel stop mode, that interrupt must first have been enabled. the i flag must also be set prior to stopping for an interrupt to cancel it. after coming out of stop mode, it is recommended that five nop instructions be executed to clear the instruction queue. when shifting to stop mode, the main clock division select bit 0 (bit 6 at 0006 16 ) is set to 1. table 1.5: port status during stop mode 2.10 wait mode when a wait instruction is executed, the internal clock f stops and the microcomputer enters the wait mode. in this mode, oscillation continues but the internal clock f and watchdog timer stop. writing 1 to the wait peripheral function clock stop bit and executing a wait instruction stops the clock being supplied to the internal peripheral functions, allowing power dissipation to be reduced. table 1.6 shows the status of the ports in wait mode. wait mode is cancelled by a hardware reset or interrupt. if an interrupt is used to cancel wait mode, the microcomputer restarts using as internal clock f the clock that had been selected when the wait instruction was executed table 1.6: port status during wait mode 2.11 status transition of the internal clock f power dissipation can be reduced and low-voltage operation achieved by changing the count source for internal clock f . table 1.7 shows the operating modes corresponding to the settings of system clock control registers 0 and 1. after a reset, operation defaults to division by 8 mode. when shifting to stop mode, the main clock division select bit 0 (bit 6 at address 0006 16 ) is set to 1. the following shows the operational modes of internal clock 2.11.1 division by 2 mode the main clock is divided by 2 to obtain the internal clock f . pin single-chip mode port retains status before stop mode clkout retains status before stop mode pin single-chip mode port retains status before stop mode clkout does not stop when the wait peripheral function clock stop bit is 0 when the wait peripheral function clock stop bit is 1, the status immediately prior to entering wait mode is maintained.
1-27 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change power control 2.11.2 division by 4 mode the main clock is divided by 4 to obtain the internal clock f . 2.11.3 division by 8 mode the main clock is divided by 8 to obtain the internal clock f . note that oscillation of the main clock must have stabilized before transferring from this mode to another mode. 2.11.4 division by 16 mode the main clock is divided by 16 to obtain the internal clock f . 2.11.5 no-division mode the main clock is used as internal clock. table 1.7: operating modes dictated by settings of system clock control registers 0 and 1 2.12 power control the following is a description of the three available power control modes: 2.12.0.1 normal operation mode ? high-speed mode divide-by-1 frequency of the main clock become the internal clock f . the cpu operates with the internal clock selected. each peripheral function operates according to its assigned clock. ? medium-speed mode divide-by-2, divide-by-4, divide-by-8, or divide-by-16 frequency of the main clock becomes the internal clock f . the cpu operates according to the internal clock selected. each peripheral function operates according to its assigned clock. 2.12.0.2 wait mode the cpu operation is stopped. the oscillators do not stop. 2.12.0.3 stop mode all oscillators stop. the cpu and all built-in peripheral functions stop. of the three modes listed, this mode is the most effective in decreasing power consumption. cm17 cm16 cm06 operating mode of internal clock 0 1 0 division by 2 mode 1 0 0 division by 4 mode invalid invalid 1 division by 8 mode 1 1 0 division by 16 mode 0 0 0 no-division mode
1-28 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change protection 2.13 protection the protection function is provided so that the values in important registers cannot be changed in the event that the program runs out of control. figure 1.14 shows the protect register. the values in the processor mode register 0 (address 0004 16 ), processor mode register 1 (address 0005 16 ), system clock control register 0 (address 0006 16 ), system clock control register 1 (address 0007 16 ) and frequency synthesizer registers can only be changed when the respective bit in the protect register is set to 1. the system clock control registers 0 and 1 write-enable bit (bit 0 at 000a 16 ) and processor mode register 0 and 1 write-enable bit (bit 1 at 000a 16 ) do not automatically return to 0 after a value has been written to an address. the program must therefore be written to return these bits to 0. figure 1.14: protect register protect register symbol address when reset prcr 000a 16 xxxxx000 2 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 0 : write-inhibited 1 : write-enabled prc1 prc0 enables writing to processor mode registers 0 and 1 (addresses 0004 16 and 0005 16 ) function 0 : write-inhibited 1 : write-enabled enables writing to system clock control registers 0 and 1 (addresses 0006 16 and 0007 16 ) and frequency synthesizer registers (addresses 03db 16 to 03df 16 ) w r nothing is assigned. these bits can neither be set nor reset. when read, their contents are indeterminate. reserved bit must always be set to "0"
1-29 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change interrupts 2.14 interrupts table 1.8 and table 1.9 show the interrupt sources and vector table addresses. when an interrupt is received, the program is executed from the address shown by the respective interrupt vector. the vector table addresses for the interrupts in table 7 are fixed (interrupt vector addresses). these interrupts are not affected by the interrupt enable flag (i flag) (non-maskable interrupts). the vector table addresses for the interrupts in table 8 are variable, being determined as relative to the fixed address in the interrupt table register (intb). these interrupts can be enabled or disabled using the interrupt enable flag (i flag) (maskable interrupts). sixty four vectors can be set in the interrupt table register (intb). any of software interrupts 0 to 63 can be assigned to each vector. by using the int instruction to specify a software interrupt number, the program can be executed starting at the address indicated by the respective vector. the brk instruction interrupt has interrupt vectors in both the fixed vector address and variable vector address. when the contents of fffe4 16 through fffe7 16 are all ff 16 ), the program is executed from the address shown in the brk instruction interrupt vector in the variable vector address. specify the starting address of the interrupt program in the interrupt vector. figure 1.15 shows the format for specifying the address. note: interrupts used for debugging purposes only figure 1.15: format for specifying interrupt vector addresses table 1.8: interrupt vectors (?xed interrupt vector addresses) interrupt source vector table addresses address(l) to address(h) remarks unde?ned instruction fffdc 16 to fffdf 16 interrupt on und instruction over?ow fffe0 16 to fffe3 16 interrupt on into instruction brk instruction fffe4 16 to fffe7 16 if the vector is ?lled with ff 16 , program execution starts from the address shown by the vector in the variable vector table address match fffe8 16 to fffeb 16 there is an address-matching interrupt enable bit single step (note) fffec 16 to fffef 16 do not use watchdog timer ffff0 16 to fff3 16 dbc (note) ffff4 16 to ffff7 16 do not use nmi ffff8 16 to ffffb 16 external interrupt by nmi pin reset ffffc 16 to fffff 16 aaaaaaaaa aaaaaaaaa mid address aaaaaaaaa aaaaaaaaa low address aaaaaaaaa aaaaaaaaa 0 0 0 0 high address aaaaaaaaa aaaaaaaaa 0 0 0 0 0 0 0 0 vector address + 0 vector address + 1 vector address + 2 vector address + 3 lsb msb
1-30 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change interrupts table 1.9: interrupt vectors (variable interrupt vector addresses) note 1:address relative to address in interrupt table base address register (intb) software interrupt number vector table addresses address(l) to address(h) interrupt source remarks software interrupt number 0 +0 to +3 (note 1) brk instruction cannot be masked by i ?ag software interrupt number 4 +16 to +19 usb suspend software interrupt number 6 +24 to +27 usb resume software interrupt number 7 +28 to +31 usb start of frame software interrupt number 10 +40 to +43 bus collision detection software interrupt number 11 +44 to +47 dma0 software interrupt number 12 +48 to +51 dma1 software interrupt number 13 +52 to +55 key input interrupt software interrupt number 14 +56 to +59 a-d software interrupt number 15 +60 to +63 uart2 transmit software interrupt number 16 +64 to +67 uart2 receive software interrupt number 17 +68 to +71 uart0 transmit software interrupt number 18 +72 to +75 uart0 receive software interrupt number 19 +76 to +79 uart1 transmit software interrupt number 20 +80 to +83 uart1 receive software interrupt number 21 +84 to +87 timer a0 software interrupt number 22 +88 to +91 timer a1 software interrupt number 23 +92 to +95 timer a2 software interrupt number 24 +96 to +99 timer a3 software interrupt number 25 +100 to +103 timer a4 software interrupt number 26 +104 to +107 timer b0 software interrupt number 27 +108 to +111 timer b1 software interrupt number 28 +112 to +115 usb reset software interrupt number 29 +116 to +119 int0 software interrupt number 30 +120 to +123 int1 software interrupt number 31 +124 to +127 usb function software interrupt number 32 to software interrupt number 63 +252 to +255 software interrupt cannot be masked by i ?ag
1-31 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change interrupts 2.14.1 interrupt control registers peripheral i/o interrupts have their own interrupt control registers. table 1.10 shows the addresses of the interrupt control registers. figure 1.16 shows the interrupt control registers. the interrupt request bit is set by hardware to 0 when an interrupt request is received. the interrupt request bit can also be set by software to 0. (do not set to 1.) int0 and int1 are triggered by the edges of external inputs. the edge polarity is selected using the polarity select bit. (other interrupts are described elsewhere.) an interrupt must first be enabled before it can be used to cancel stop mode. table 1.10: addresses in interrupt control register interrupt control register symbol name address interrupt control register symbol name address usb suspend interrupt suspic 0044 16 uart1 receive s1ric 0054 16 usb resume interrupt rsmic 0046 16 timer a0 ta0ic 0055 16 usb start of frame sofic 0047 16 timer a1 ta1ic 0056 16 bus collision detection bcnic 004a 16 timer a2 ta2ic 0057 16 dma0 dm0ic 004b 16 timer a3 ta3ic 0058 16 dma1 dm1ic 004c 16 timer a4 ta4ic 0059 16 key input interrupt kupic 004d 16 timer b0 tb0ic 005a 16 a-d adic 004e 16 timer b1 tb1ic 005b 16 uart2 transmit s2tic 004f 16 usb reset rstic 005c 16 uart2 receive s2ric 0050 16 int0 int0ic 005d 16 uart0 transmit s0tic 0051 16 int1 int1ic 005e 16 uart0 receive s0ric 0052 16 usb function usbfic 005f 16 uart1 transmit s1tic 0053 16
1-32 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change interrupts figure 1.16: interrupt control registers symbol address when reset intiic ( i= 0, 1) 005d 16, 005e 16 xx00x000 2 sofic 0047 16 xx00x000 2 interrupt control register symbol address when reset suspic 0044 16 xxxxx000 2 rsmic 0046 16 xxxxx000 2 bcnic 004a 16 xxxxx000 2 dmiic(i=0, 1) 004b 16 , 004c 16 xxxxx000 2 kupic 004d 16 xxxxx000 2 adic 004e 16 xxxxx000 2 sitic(i=0 to 2) 0051 16 , 0053 16 , 004f 16 xxxxx000 2 siric(i=0 to 2) 0052 16 , 0054 16 , 0050 16 xxxxx000 2 taiic(i=0 to 4) 0055 16 to 0059 16 xxxxx000 2 tbiic(i=0 to 2) 005a 16 to 005b 16 xxxxx000 2 rstic 005c 16 xxxxx000 2 usbfic 005f 16 xxxxx000 2 b7 b6 b5 b4 b3 b2 b1 b0 bit name function bit symbol w r ilvl0 ir interrupt priority level select bit interrupt request bit 0 : interrupt not requested 1 : interrupt requested ilvl1 ilvl2 nothing is assigned. these bits can neither be set nor reset. when read, their contents are indeterminate. (note) note: this bit can only be reset (= 0), but cannot be set ( = 1). 0 0 0 : level 0 (interrupt disabled) 0 0 1 : level 1 0 1 0 : level 2 0 1 1 : level 3 1 0 0 : level 4 1 0 1 : level 5 1 1 0 : level 6 1 1 1 : level 7 b2 b1 b0 bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 ilvl0 ir pol nothing is assigned. these bits can neither be set nor reset. when read, their contents are indeterminate. interrupt priority level select bit interrupt request bit polarity select bit reserved bit 0: interrupt not requested 1: interrupt requested 0 : selects falling edge 1 : selects rising edge always set to 0 ilvl1 ilvl2 (note 1) 0 0 0 : level 0 (interrupt disabled) 0 0 1 : level 1 0 1 0 : level 2 0 1 1 : level 3 1 0 0 : level 4 1 0 1 : level 5 1 1 0 : level 6 1 1 1 : level 7 b2 b1 b0 0 (note 2) note 1: this bit can only be reset (=0), but cannot be set (=1). note 2: for sofic (address 0047 16 ), a "0" should always be written.
1-33 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change interrupts 2.14.2 interrupt priority the order of priority when two or more interrupts are generated simultaneously is determined by both hardware and software. the interrupt priority levels determined by hardware are reset > nmi > dbc > watchdog timer > pe- ripheral i/o interrupts > single-step > address matching interrupt. the interrupt priority levels determined by software are set in the interrupt control registers. figure 1.17 shows the circuit that judges the interrupt hardware priority level. when two or more inter- rupts are generated simultaneously, the interrupt with the higher software priority is selected. howev- er, if the interrupts have the same software priority level, the interrupt is selected according to the hardware priority set in the circuit. the selected interrupt is accepted only when the priority level is higher than the processor interrupt priority level (ipl) in the flag register (flg) and the interrupt enable flag (i flag) is 1. note that the reset, nmi, dbc, watchdog timer, single-step, address-match, brk instruction, overflow, and unde- fined instruction interrupts are accepted regardless of the interrupt enable flag (i flag).
1-34 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change interrupts figure 1.17: interrupt resolution circuit usb reset timer a4 timer a2 usb sof uart1 reception uart0 reception uart2 reception a-d conversion dma1 bus collision detection timer a0 uart1 transmission uart0 transmission uart2 transmission key input interrupt dma0 processor interrupt priority level (ipl) int1 timer b1 level 0 (initial value) priority level of each interrupt high low priority of peripheral i/o interrupts (if priority levels are same) interrupt enable flag (i flag) watchdog timer reset dbc nmi interrupt request accepted address match usb suspend usb resume usb function timer a3 timer a1 int0 timer b0
1-35 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change nmi interrupt 2.14.3 flag changes when an interrupt request is received, the stack pointer select flag (u flag) changes to 0 and the flag register (flg) and program counter (pc) are saved to the stack area indicated by the interrupt stack pointer (isp). thereafter, the interrupt enable flag (i flag) and debug flag (d flag) change to 0 and the processor interrupt priority level (ipl) at the flag register (flg) is replaced by the priority level of the received interrupt. however, when interrupt requests are received for software interrupts 32 to 63, the flag register (flg) and program counter (pc) are saved to the stack shown by the stack pointer select flag (u flag) at the time the interrupt was received. the stack pointer select flag (u flag) does not change. the value of the processor interrupt priority level (ipl) in the flag register (flg) differs in the case of reset, nmi, dbc, watchdog timer, single-step, address-match, brk instruction, overflow, and undefined instruction interrupts. table 1.11 shows how the ipl changes when interrupt requests are received. table 1.11: change of ipl state when interrupt request are accepted 2.13 nmi interrupt an n m i interrupt is generated when the input to the p85/ n m i pin changes from h to l. the n m i interrupt is a non-maskable external interrupt. the pin level can be checked in the port p85 register (bit 5 at address 03f0 16 ). this pin cannot be used as a normal port input. 2.13.1 notes: (1) when not intending to use the nmi function, be sure to connect the nmi pin to vcc. because the nmi interrupt is non-maskable, it cannot be disabled. (2) when the nmi pin input is l, do not set the microcomputer in stop mode or wait mode. the nmi interrupt is triggered by the falling edge, so the l level does not need to be maintained longer than necessary. interrupt change of ipl reset level 0 ( 000 2 ), is set nmi level 7 ( 111 2 ), is set dbc does not change watchdog timer level 7 ( 111 2 ), is set single step does not change address match does not change software interrupt does not change
1-36 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change key-input interrupt 2.14 key-input interrupt if the direction register of any of pin of port0 or port1 is set for input and a falling edge is input to that port, a key-input interrupt is generated. a key-input interrupt can also be used as a key-on wakeup function for cancelling the wait mode or stop mode. figure 1.18 shows the block diagram of the key- input interrupt. figure 1.18: block diagram of key input interrupt 2.14.1 enabling/disabling the key-input interrupt the key-input interrupt can be enabled and disabled using the key-input interrupt register (004d 16 ). the key-input interrupt is affected by the interrupt priority level (ipl) and the interrupt enable flag (i flag). 2.14.2 occurrence timing of the key-input interrupt with key-input interrupt acceptance enabled, ports p0 and p1, which are set to input, become key- input interrupt pins ( ki0 through ki15). a key-input interrupt occurs when a falling edge is input to a key-input interrupt pin. at this moment, the level of other key-input interrupt pins must be h. no in- terrupt occurs when the level of any other key-input interrupt pins is l. 2.14.3 how to determine a key-input interrupt a key-input interrupt occurs when a falling edge is input to one of 16 pins, but each pin has the same vector address.therefore, read the input level of ports p0 and p1 in the key-input interrupt routine to determine the interrupted pin. p1 i /ki j port px i pull-up select bit port p1 i direction register pull-up transistor interrupt control circuit key input interrupt control register (address 004d 16 ) key input interrupt request p0 i /ki j port p0 i pull-up select bit port p0 i direction register pull-up transistor i=0~7; j=0~7 i=0~7; j=8~15 kio 0 kio 15
1-37 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change key-input interrupt 2.14.4 registers related to the key-input interrupt figure 1.19 shows the memory map of key-input interrupt-related registers figure 1.19: memory map of key input interrupt related registers key-input interrupt control register (kupic) port 0 (p0) port 1 (p1) port 0 direction register port 1 direction register pull-up control register 0 pull-up control register 1 04d 16 3e0 16 3e1 16 3e2 16 3e3 16 3fc 16 3fd 16
1-38 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change address match interrupt 2.15 address match interrupt an address match interrupt is generated when the address match interrupt address register contents match the program counter value. two address match interrupts can be set, each of which can be enabled and disabled by an address match interrupt enable bit. address match interrupts are not affected by the interrupt enable flag (i flag) and processor interrupt priority level (ipl). figure 1.20 shows the address match interrupt-related registers. figure 1.20: address match interrupt-related registers bit name bit symbol symbol address when reset aier 0009 16 xxxxxx00 2 address match interrupt enable register function w r aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa address match interrupt 0 enable bit 0 : interrupt disabled 1 : interrupt enabled aier0 address match interrupt 1 enable bit aier1 aaaaaaaaaaaaaaaa a aaaaaaaaaaaaaa a aaaaaaaaaaaaaaaa symbol address when reset rmad0 0012 16 to 0010 16 x00000 16 rmad1 0016 16 to 0014 16 x00000 16 nothing is assigned. these bits can neither be set nor reset. when read, their contents are indeterminate. b7 b6 b5 b4 b3 b2 b1 b0 w r address setting register for address match interrupt function values that can be set address match interrupt register i (i = 0, 1) 00000 16 to fffff 16 nothing is assigned. these bits can neither be set nor reset. when read, their contents are indeterminate. 0 : interrupt disabled 1 : interrupt enabled b0 b7 b0 b3 (b19) (b16) b7 b0 (b15) (b8) b7 (b23) a a a a a a a a
1-39 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change watchdog timer 2.16 watchdog timer the watchdog timer has the function of detecting when the program is out of control. the watchdog timer is 39a 15-bit counter that decrements using the clock derived by dividing the internal clock f using the prescaler. a watchdog timer interrupt is generated when an under?ow occurs in the watchdog timer. bit 7 of the watchdog timer control register (address 000f 16 ) selects the prescaler division ratio (by 16 or 128). table 1.12 shows the periodic table for the watchdog timer. table 1.12: watchdog timer periodic table (f(x in )=10mhz) the watchdog timer is initialized by writing to the watchdog timer start register (address 000e 16 ) and when a watchdog timer interrupt request is generated. the prescaler is initialized only when the microcomputer is reset. after a reset is cancelled, the watchdog timer and prescaler are both stopped. the count is started by writing to the watchdog timer start register (address 000e 16 ). figure 1.21 shows the block diagram of the watchdog timer. figure 1.22 shows the watchdog timer- related registers. cm06 cm17 cm16 internal clock f wdc7 period 0 0 0 10mhz 0 approx. 52.4ms 1 approx. 419.2ms 0 0 1 5mhz 0 approx. 104.9ms 1 approx. 838.8ms 0 1 0 2.5mhz 0 approx. 209.7ms 1 approx. 1.68s 0 1 1 0.625mhz 0 approx. 838.8ms 1 approx. 6.71s 1 invalid invalid 1.25mhz 0 approx. 419.2ms 1 approx. 3.35s
1-40 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change watchdog timer figure 1.21: block diagram of watchdog timer figure 1.22: watchdog timer control and start registers 1/16 1/128 watchdog timer watchdog timer interrupt request set to 7fff 16 wdc7 = 0 wdc7 = 1 reset write to the watchdog timer start register (address 000e 16 ) internal clock f watchdog timer control register symbol address when reset wdc 000f 16 000xxxxx 2 function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 high-order bit of watchdog timer wdc7 bit name prescaler select bit 0 : divided by 16 1 : divided by 128 watchdog timer start register symbol address when reset wdts 000e 16 indeterminate w r b7 b0 function the watchdog timer is initialized and starts counting after a write instruction to this register. the watchdog timer value is always initialized to 7fff 16 regardless of whatever value is written. reserved bit reserved bit must always be set to 0 must always be set to 0 0 0 aa aa aa aa a a aa aa a a aa aa a a a
1-41 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change frequency synthesizer circuit 2.17 frequency synthesizer circuit the frequency synthesizer circuit generates a 48mhz clock needed by the usb block and a clock f syn that are both a multiple of the external input reference clock f(xin). a block diagram of the circuit is shown in figure 1.23. figure 1.23: frequency synthesizer circuit the frequency synthesizer consists of a prescaler, frequency multiplier macro, a frequency divider macro, and five registers, namely fsp, fsm, fsc, fsd, and fsccr. clock f(xin) is prescaled down using fsp to generate f pin .f pin is multiplied using fsm to generate an f vco clock which is then divided using fsd to produce the clock f syn . the f vco clock is optimized for 48 mhz operation and is buffered and sent out of the frequency synthesizer block as signal f usb . this signal is used by the usb block. 2.17.1 prescaler clock f pin is a divided down version of clock f(xin) (see figure 1.24). the relationship between f pin and the clock input to the prescaler f(xin) is as follows: ?f pin = f(xin) / 2(n+1) where n is a decimal number between 0 and 254. setting fsp to 255 disables the prescaler and f pin = f(xin). ? note: f(xin) frequency below 1 mhz is not recommended. figure 1.24: frequency synthesizer prescaler register (fsp) fsp data bus fsm fsc fsd 03de 03dd 03dc 03df frequency multiplier frequency divider 8 bit ls 8 bit f(xin) f vco f syn f usb prescaler 8 bit f pin fsccr fsccr0 03db en usbc5 2 f pin fsp f(xin) dec(n) hex(n) 12 mhz 255 ff 12.00 mhz 1 mhz 5 05 12.00 mhz 2 mhz 2 02 12.00 mhz 3 mhz 1 01 12.00 mhz 6 mhz 0 00 12.00 mhz msb 7 lsb 0 bit 6 bit 1 bit 0 bit 2 bit 5 bit 4 bit 3 bit 7 access: r/w address: 03de 16 reset: ff 16 f(xin) /2( n +1) = f pin
1-42 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change frequency synthesizer circuit 2.17.2 multiplier clock f vco is a multiplied up version of clock f pin (see figure 1.25). the relationship between f vco and the clock input to the multiplier (f pin ) from the prescaler is as follows: ?f vco = f pin x 2( n +1) where n is the decimal equivalent of the value loaded in fsm. setting fsm to 255 disables the multiplier and f vco = f pin . note 1: n must be chosen such that f vco equals 48 mhz. note 2: minimum f pin is 1 mhz. figure 1.25: frequency synthesizer multiply register (fsm) 2.17.3 divider clock f syn is a divided down version of clock f vco (see figure 1.26). the relationship between f syn and the clock input to the divider (f vco ) from the multiplier is as follows: ?f syn = f vco / 2(m+1) where m is the decimal equivalent of the value loaded in fsd. setting fsd to 255 disables the divider and f syn = f vco . figure 1.26: frequency synthesizer divide register (fsd) f pin x2( n +1)=f vco f pin fsm f vco dec(n) hex(n) 1 mhz 33 4a 48.00 mhz 2 mhz 11 0b 48.00 mhz 4 mhz 5 05 48.00 mhz 6 mhz 3 03 48.00 mhz 12 mhz 1 01 48.00 mhz msb 7 lsb 0 bit 6 bit 1 bit 0 bit 2 bit 5 bit 4 bit 3 bit 7 address: 03dd 16 access: r/w reset: ff 16 f vco /2(m+1) = f syn f vco fsd f syn dec(m) hex(m) 48.00 mhz 1 01 12.00 mhz 48.00 mhz 127 7f 187.50 khz msb 7 lsb 0 bit 6 bit 1 bit 0 address: 03df 16 access: r/w reset: ff 16 bit 2 bit 5 bit 4 bit 3 bit 7
1-43 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change frequency synthesizer circuit the fsc0 bit in the fsc control register enables the frequency synthesizer block. when disabled (fsc0 = 0), f vco is held at either a high or low state. when the frequency synthesizer control bit is active (fsc0 = 1), a lock status (ls = 1) indicates that f syn and f vco are the correct frequency. the ls and fsco control bits in the fsc control register are shown in figure 1.27. when using the frequency synthesizer, a low-pass filter must be connected to the lpf pin. once the frequency synthesizer is enabled, a delay of 2-5ms is recommended before the output of the frequency synthesizer is used. this is done to allow the output to stabilize. it is also recommended that none of the registers be modified once the frequency synthesizer is enabled as it will cause the output to be temporarily (2-5ms) unstable. the mcu clock source is selected via the frequency synthesizer clock control register (fsccr). see figure 1.28. note: none of the registers must be written to once the frequency synthesizer is enabled and used as the system clock source (fsccr register, address 03db 16 , bit 0 set to 1) because it will cause the output of the pll to freeze. switch system back to f(x in ) and disable before modifying pll registers. figure 1.27: frequency synthesizer control register (fsc) figure 1.28: frequency synthesizer clock control register (fsccr) frequency synthesizer control register symbol address when reset fsc 03dc 16 60 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 0 : disable 1 : enabled vco0 fse vco gain control function bit 2 bit 1 0 0: lowest gain (note 1) 0 1: low gain 1 0: high gain 1 1: highest gain frequency synthesizer enable w r reserved bit must always be set to "0" vco1 chg0 chg1 lpf current control bit 6 bit 5 0 0: disabled 0 1: low current 1 0: intermediate current (note 1) 1 1: high current ls frequency synthesizer lock status 0: unlocked 1: locked note 1: recommended 0 0 frequency synthesizer clock control register symbol address when reset fsccr 03db 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 0 : xin 1 : fsyn fsccr0 function w r reserved must always be set to "0" clock source selection 0 0 0 0 0 0 0
1-44 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus 2.18 universal serial bus the universal serial bus (usb) has the following features: ? complete usb speci?cation (version 1.1) compatibility ? error-handling capabilities ? fifos: ? endpoint 0: in/out 32-byte ? endpoint 1: in 128-byte out 128-byte ? endpoint 2: in 32-byte out 32-byte ? endpoint 3: in 32-byte out 32-byte ? endpoint 4: in 32-byte out 32-byte ? nine endpoints - control endpoint (endpoint 0 - bi-directional) plus four in and four out endpoints ? complete device con?guration ? support of all device commands ? supports of full-speed functions ? support of all usb transfer types: ? isochronous ? bulk ? control ? interrupt ? suspend/resume operation ? on-chip usb transceiver with voltage converter ? start-of-frame interrupt and output pin 2.18.1 usb function control unit (usb fcu) the implementation of the usb by this device is accomplished chiefly through the devices usb function control unit (see figure 1.29). the function control units overall purpose is to handle the usb packet protocol layer. the function control unit notifies the mcu that a valid token has been received. when this occurs, the data portion of the token is routed to the appropriate fifo. the mcu transfers the data to, or from, the host by interacting with that endpoints fifo and csr register. the usb function control unit is composed of five sections: ? serial interface engine (sie) ? generic function interface (gfi) ? serial engine interface unit (siu) ? microcontroller interface (mci) ? usb transceiver 2.18.1.1 serial interface engine the sie interfaces to the usb serial data and handles deserialization/serialization of data, nrzi encoding decoding, clock extraction, crc generation and checking, bit stuffing, and other items pertaining to the usb protocol such as handling inter-packet time-outs and packet id (pid) decoding.
1-45 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus 2.18.1.2 generic function interface the gfi handles all usb standard requests from the host through the control endpoint (endpoint zero), han- dles bulk, isochronous and interrupt transfers through endpoints 1-4. the gfi handles read pointer reversal for re-transmission the current data set; write pointer reversal for reception of the last data set again and data toggle synchronization. 2.18.1.3 serial engine interface unit the siu block decodes the address and endpoint fields from the usb host. 2.18.1.4 microcontroller interface the mci block handles the microcontroller interface and performs address decoding and synchronization of control signals. 2.18.1.5 usb transceiver the usb transceiver, designed to interface with the physical layer of the usb, is compliant with the usb specification (version 1.1) for full-speed devices. it consists of two 6-ohm drivers, a receiver, and schmitt trig- gers for single-ended receive signals. the transceiver also includes a voltage converter. the voltage converter can supply 3.0 - 3.6v to the trans- mitter when the rest of the chip (cpu, usb fcu) operates at 4.15 - 5.25v. to enable the voltage converter, set bit 4 of the usb control register (usbc) to a 1. to disable the voltage converter, set bit 4 of the usbc to a 0. refer to section 5.4 usb transceiver for more detailed information. figure 1.29: usb function control unit block diagram 2.18.2 usb interrupts there are five usb interrupts in this device: ? usb function interrupt ? usb reset interrupt ? usb suspend interrupt ? usb resume interrupt ? usb start-of-frame (sof) interrupt. the first four interrupts are used to control the data flow and usb power. the sof interrupt is used to monitor the transfer of isochronous (iso) data. each of the five usb interrupts is enabled by setting the corresponding bit in the interrupt control register of the interrupt control unit. because the usb function interrupt has mul- tiple interrupt sources, another level of enabling is within the usb interrupt registers 1 & 2. cpu mci siu gfi fifos sie transceiver d + d -
1-46 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus 2.18.2.1 usb function interrupt the usb function interrupt can be triggered by 10 sources; many of these may be cause by several different events. interrupt status flags associated with each source are contained in usbis1 and usbis2. endpoints 1-4 have two interrupt status flags associated with it to control data transfer or to report a stall/ under_run/over run condition. the usb endpoint x out interrupt status flag is set when ? usb fcu successfully receives a packet of data or ? usb fcu sets the force_stall bit or over_run bit of the endpoint x out csr. the usb endpoint x in interrupt status is set when ? usb fcu successfully sends a packet of data or ? usb fcu sets the under_run bit of the endpoint x in csr. the usb endpoint 0 (control endpoint) has one interrupt status bit associated with it to control data transfer or report a stall condition. the usb endpoint 0 interrupt status flag is set when ? usb fcu successfully receives/sends a packet of data ? sets the setup_end bit or the force_stall bit, or clears the data_end bit in the endpoint 0 in csr. the overrun/underrun interrupt status flag is set when (applicable to endpoints used for isochronous data transfer) ? overrun condition occurs in a endpoint (cpu is too slow to unload the data from the fifo), or ? underrun condition occurs in an endpoint (cpu is too slow to load the data to the fifo). each endpoint interrupt and overrun/underrun interrupt is enabled by setting the corresponding bit in the usb interrupt enable register 1 and 2. 2.18.2.2 usb reset interrupt the usb reset interrupt status flag is set when the usb fcu sees a se0 present on d+/d- for at least 2.5 m s. when this bit is set, all usb internal registers except intst13 (bit5 of usbis2) are reset to their default values. intst13, the usb reset interrupt status flag, is set to a 1 when the usb reset is detected. when the cpu recognizes a usb reset interrupt, it needs to re initialize the usb fcu so that the usb op- eration can behave properly. it must also clear intst13 by writing a 1 to this bit to allow a usb reset inter- rupt request to occur the next time a usb reset is detected. register rstic contains the usb reset interrupts request bit and its interrupt priority select bits which are used to enable the interrupt and set its software priority level. 2.18.2.3 usb suspend and resume interrupts the usb suspend interrupt is set when the usb fcu does not detect any bus activity on d+/d- (in j-state) for at least 3ms. the usb suspend signaling interrupt status flag (intst15, bit 7 of usbis2) is set to a 1 when the usb suspend is detected. the cpu must clear intst15 by writing a 1 to this bit to allow a usb suspend interrupt request to occur the next time a usb suspend is detected. the usb resume signaling interrupt status flag is set when a usb fcu is in the suspend state and detects non-idle signaling on the d+/d-. register suspic contains the usb suspend interrupts request bit and its interrupt priority select bits which are used to enable the interrupt and set its software priority level. the usb resume interrupt request is set when the usb fcu is in the suspend state and detects non-idle signaling on d+/d-. the usb signaling interrupt status flag (intst14, bit 6 of usbis2) is set to a 1 when the usb resume is detected. the cpu must clear intst14 by writing a 1 to this bit to allow a usb resume interrupt request to occur the next time a usb resume is detected. register rsmic contains the usb resume interrupts request bit and its interrupt priority select bits, which are used to enable the interrupt an set its software priority level.
1-47 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus 2.18.2.4 usb sof interrupt the usb sof (start-of-frame) interrupt is used to control the transfer of isochronous data. the usb fcu generates a usb sof interrupt request when a start-of-frame packet is received. register sofic contains the usb sof interrupts request bit and its interrupt priority select bits, which are used to enable the interrupt and set its software priority level. 2.18.3 usb endpoint fifos the usb fcu has an in (transmit) fifo and an out (receive) fifo for each endpoint. each endpoint (ex- cept endpoint 0) can be configured to support either single packet mode (in which only a single data packet is allowed to reside in the endpoints fifo) or dual packet mode (in which up to two data packets are allowed to reside in the endpoints fifo). dual packet mode provides support for back-to-back transmission or back- to-back reception. the mode is automatically determined by the maxp value. when maxp > 1/2 of the end- points fifo size, single packet mode is set. when maxp <= 1/2 of the endpoints fifo size, dual packet mode is set. in the event of a bad transmission/reception, the usb fcu handles all the fifo read/write pointer reversal and data set management tasks required. throughout this specification, the terms in fifo and out fifo usually refer to the fifos associated with a specific endpoint. 2.18.3.1 in (transmit) fifos the cpu/dma writes data to the endpoints in fifo location specified by the fifo write pointer, which auto- matically increments by 1 after a write. the cpu/dma should only write data to the in fifo when the in_pkt_rdy bit of the associated in csr is a 0. ? endpoint 0 in fifo operation: the cpu writes a 1 to the in_pkt_rdy bit of endpoint 0 csr after it finishes writing a packet of data to the in fifo. the usb fcu clears the in_pkt_rdy bit after the packet has been successfully transmitted to the host (i.e., ack is received from the host) or the setup_end bit of the in csr is set to a 1. ? endpoint 1-4 in fifo operation when auto_set (bit 7 of endpoint x in csr) = 0 (disabled): maxp > 1/2 of the in fifo size: the cpu writes a 1 to the in_pkt_rdy bit of the associated in csr after the cpu/dmac finishes writing a packet of data to the in fifo. the usb fcu clears the in_pkt_rdy bit after the packet has been successfully transmitted to the host (which is assumed for isochronous transfers and is concluded when an ack is received from the host for non-isochronous transfers). maxp <= 1/2 of the in fifo size: the cpu writes a 1 to the in_pkt_rdy bit of the associated in csr after the cpu/dmac finishes writing a packet of data to the in fifo. the usb fcu clears the in_pkt_rdy bit as soon as the in fifo is ready to accept another data packet. (the fifo can hold up to two data packets at the same time in this configuration for back-to-back transmission.) ? endpoint 1-4 in fifo operation when auto_set (bit 7 of endpoint x in csr) = 1 (enabled): maxp > 1/2 of the in fifo size: when the number of bytes of data equal to the maxp (maximum packet size) has been written to the in fifo by the cpu/dmac, the usb fcu sets the in_pkt_rdy bit of the associated in csr to a 1 automatically. the usb fcu clears the in_pkt_rdy bit after the packet has been success- fully transmitted to the host (which is assumed for isochronous transfers and is concluded when an ack is received from the host for non-isochronous transfers). maxp <= 1/2 of the in fifo size: when the number of bytes of data equal to the maxp (maximum packet size) has been written to the in fifo by the cpu/dmac, the usb fcu sets the in_pkt_rdy bit to a 1 automatically. the usb fcu clears the in_pkt_rdy bit as soon as the in fifo is ready to accept another data packet. (the fifo can hold up to two data packets at the same time in this configuration for back-to-back transmission.) a software or a hardware flush causes the usb fcu to act as if a packet has been successfully transmitted out to the host. when there is one packet in the in fifo, a flush causes the in fifo to be empty. when there are two packets in the in fifo, a flush causes the older packet to be flushed out from the in fifo. a flush also updates the in fifo status bits in_pkt_rdy and tx_not_empty of the associated in csr.
1-48 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus the status of endpoint 1-4 in fifos for both of the above cases can be obtained from the in csr of the cor- responding in fifo as shown in table 1.13 . 2.18.3.2 out (receive) fifos the usb fcu writes data to the endpoints out fifo location specified by the fifo write pointer, which au- tomatically increments by one after a write. when the usb fcu has successfully received a data packet, it sets the out_pkt_rdy bit of the corresponding out csr to a 1. the cpu/dmac should only read data from the out fifo when the out_pkt_rdy bit of the out csr is a 1. ? endpoint 0 out fifo operation: the usb fcu sets the out_pkt_rdy bit to a 1 after it has successfully received a packet of data from the host. the cpu sets bit serviced_out_pkt_rdy to a 1 to clear the out_pkt_rdy bit after the packet of data has been unloaded from the out fifo by the cpu. ? endpoint 1-4 out fifo operation when auto_clr (bit 7 of endpoint x out csr) = 0 (disabled): maxp > 1/2 of the out fifo size: the usb fcu sets the out_pkt_rdy bit of the associated in csr to a 1 after it has successfully received a packet of data from the host. the cpu writes a 0 to the out_pkt_rdy bit after the packet of data has been unloaded from the out fifo by the cpu/dmac. maxp <= 1/2 of the out fifo size: the usb fcu sets the out_pkt_rdy bit of the associated in csr to a 1 after it has successfully received a packet of data from the host. the cpu writes a 0 to the out_pkt_rdy bit after the packet of data has been unloaded from the out fifo by the cpu/dmac. if an- other packet is in the out fifo, the out_pkt_rdy bit will be set to a 1 again almost immediately (such that it may appear that the out_pkt_rdy bit remains a 1). in this configuration, the fifo can store up to two data packets at the same time for back-to-back reception. ? endpoint 1-4 out fifo operation when auto_clr (bit 7 of endpoint x out csr) = 1 (enabled): maxp > 1/2 of the out fifo size: the usb fcu sets the out_pkt_rdy bit of the associated in csr to a 1 after it has successfully received a packet of data from the host. the usb fcu clears the out_pkt_rdy bit to a 0 automatically when the number of bytes of data equal to the maxp (maximum packet size) has been unloaded from the out fifo by the cpu/dmac. maxp <= 1/2 of the out fifo size: the usb fcu sets the out_pkt_rdy bit of the associated in csr to a 1 after it has successfully received a packet of data from the host. the usb fcu clears the out_pkt_rdy bit to a 0 automatically when the number of bytes of data equal to the maxp (maximum packet size) has been unloaded from the out fifo by the cpu/dmac. if another packet is in the out fifo, the out_pkt_rdy bit will be set to a 1 again almost immediately (such that it may appear that the out_pkt_rdy bit remains a 1). in this configuration, the fifo can store up to two data packets at the same time for back-to-back reception. a software flush causes the usb fcu to act as if a packet has been unloaded from the out fifo. if there is one packet in the out fifo, a flush will cause the out fifo to be empty. if there are two packets in the out fifo, a flush will cause the older packet to be flushed out from the out fifo. table 1.13: ta fifo status in_pkt_rdy tx_not_empty in fifo status 00 no data packet in in fifo 01 one data packet in in fifo if maxp <= 1/2 of the fifo size./ invalid when maxp>1/2 of the fifo size 10 invalid 11 two data packets in in fifo when maxp <=1/2 of the fifo size one data packet in in fifo when maxp > 1/2 of the fifo size
1-49 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus 2.18.3.3 interrupt endpoints: any endpoint can be used for interrupt transfers. for normal interrupt transfers, the interrupt transactions be- have the same as bulk transactions, i.e., no special setting is required. the in endpoints may also be used to communicate rate feedback information for certain types of isochronous functions. this is done by setting the intpt bit in the in csr register of the corresponding endpoint. the following outlines the operation sequence for an in endpoint used to communicate rate feedback infor- mation: 1. set maxp > 1/2 of the endpoints fifo size; 2. set intpt bit of the in csr; 3. flush the old data in the fifo; 4. load interrupt status information and set in_pkt_rdy bit in the in csr; 5. repeat steps 3 & 4 for all subsequent interrupt status updates. 2.18.4 usb special function registers the mcu controls usb operation through the use of special function registers (sfr). this section de- scribes each usb related sfr. some usb special function registers have a mix of read/write, read only, and write only register bits. additionally, the bits may be configured to allow the user to write only a 0 or a 1 to individual bits. ? when accessing these registers, writing a 0 to a register that can only be set to a 1 by the cpu has no effect on that register bit. ? writing a 1 to a register that can only be set to a 0 by the cpu has not effect on that register bit. each figure and description of the special function registers details this operation. all usb special function registers, with the exception of usb attach/detach (001f 16 ) and usb con- trol (000c 16 ) must use byte access. work access is prohibited for usb internal registers (0300 16 - 033c 16 ). the contents of all usb special functions registers, including usb attach/detach and usb control, are preserved on a software reset. 2.18.4.1 usb attach/detach register the usb attach / detach register is shown in figure 1.30. the register is used to attach and detach the usb function from a usb host without physically disconnecting the usb cable. this functionality is enabled by set- ting p83_second to a 1. doing this forces p83 to operate as a pull-up for d+ (through an external 1.5k ohm resistor). the port driver is tri-stated and a 1 is always read from the port bit in this mode. when the attach/detach bit is a 1 (and p83_second is a 1), p83 is driven with the voltage on extcap, caus- ing d+ to be pulled up and the host to detect an attach. when the attach/detach bit is a 0 (and p83_second is a 1), p83 is tri-stated, causing d+ to be pulled down (through the cable and 15k ohm re- sistor on the host/hub side) and a detach to be registered by the host. a 1.5k ohm pull-up resistor must be connected externally from p83 to d+ when this functionality is used. when it is not used, the 1.5k ohm resistor should be placed between extcap and d+. figure 1.30: usb attach/detach register usb attach/detach register symbol address when reset usbad 001f 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 0 : normal mode for port 8_3 1 : forces port 8_3 to operate as pull up for d+. p83_2nd function reserved must always be set to "0" port 83-second attach/ detach attach/detach 0 : tri-states, p8_3 causing the host to detect a detach 1 : drives p8_3 with voltage on extcap, causing the host to detect an attach w r 0 0 0 0 0 0
1-50 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus 2.18.4.2 usb control register the usb control register, shown in figure 1.31 , is used to control the usb fcu. this register is not reset by a usb reset signaling. after the usb is enabled (usbc7 set to 1), a minimum delay of 250ns (three 12 mhz clock periods) is needed before performing any other usb register read/write operations. figure 1.31: usb control register 2.18.4.3 usb function address register the usb function address register, shown in figure 1.32, maintains the 7-bit usb address assigned by the host. the usb fcu uses this register value to decode usb token packet addresses. at reset, when the de- vice is not yet configured, the value is 00 16 . for the procedures on how to update this register, refer to appli- cation notes usb consecutive set address. figure 1.32: usb function address register usb control register symbol address when reset usbc 000c16 0016 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 function w r must always be set to "0" reserved usbc3 usbc4 usbc5 usbc6 usbc7 tranceiver voltage converter high/low current mode selection usb tranceiver voltage converter enable bit usb clock enable bit usb sof port select bit usb enable bit 0: high current mode (note 1) 1: low current mode (note 2) 0: disabled 1: enabled 0: disabled 1: enabled 0: disabled (note 3) 1: enabled 0: disabled (note 4) 1: enabled note 1: for usb normal operation note 2: for usb suspend operation note 3: p8 6 is used as gpio pin note 4: all usb internal registers are held at their default values. 0 0 0 function address register symbol address when reset usba 0300 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 funad0-6 function w r reserved must always be set to "0" 7-bit programmable function address function address 0
1-51 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus 2.18.4.4 the usb power management register the usb power management register, shown in figure 1.33, is used for power management in the usb fcu. ? suspend detection flag: when the usb fcu does not detect any bus activity on d+/d- for at least 3ms (and d+/d- are in the j-state), it sets the suspend detection flag and generates an interrupt. this bit is cleared when signaling from the host is detected on d+/d- (which sets the resume detection flag and generates an interrupt), or the remote wake-up bit is set and then cleared by the cpu. if the usb clock was disabled during the suspend state, the suspend detection flag is not cleared until after the usb clock is re-enabled. ? resume detection flag: when the usb fcu is in the suspend state and detects activity on d+/d- from the host, it sets the resume detection flag and generates an interrupt. the cpu writes a 1 to intst14 (bit 6 of usb interrupt status register 2) to clear this flag. ? wakeup control bit: the cpu writes a 1 to the wakeup control bit for remote wake-up. while this bit is set and the usb fcu is in suspend mode, resume signaling is sent to the host. the cpu must keep this bit set for a minimum of 10ms and a maximum of 15ms before writing a 0 to this bit. figure 1.33: usb power management register usb power management register symbol address when reset usbpm 0301 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 function w r reserved must always be set to "0" suspend resume wakeup usb suspend detection flag usb resume detection flag usb remote wakeup bit 0 : no usb suspend signal detected 1 : usb suspend signal detected 0 : no usb resume signal detected 1 : usb resume signal detected 0 : end remote resume signaling 1 : remote resume signaling (note 2) note 1: write "0" only or read note 2: if suspend = "1" note 1 note 1 0 0 0 0 0
1-52 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus 2.18.4.5 usb interrupt status registers 1 and 2 usb interrupt status registers 1 and 2 , shown in figure 1.34 and figure 1.35, are used to indicate the con- dition that caused a usb function interrupt and usb reset, suspend and resume interrupts to the cpu. a 1 indicates the corresponding condition caused an interrupt. the usb interrupt status register bits can be cleared by writing a 1 to the corresponding bit. intst0 is set to a 1 by the usb fcu when (in endpoint 0 csr): ?a packet of data is successfully received (ep0csr0 - out_pkt_rdy is set by the usb fcu) ?a packet of data is successfully sent (ep0csr - in_pkt_rdy is cleared by the usb fcu) ?ep0csr3 (data_end) bit is cleared by the usb fcu ?ep0csr4 (force_stall) bit is set by the usb fcu ?ep0csr5 (setup_end) bit is set by the usb fcu intst2, intst4, intst6 or intst8 is set to a 1 by the usb fcu when (in endpoint x in csr): ?a packet of data is successfully sent (inxcsr0 - in_pkt_rdy is cleared by the usb fcu) ?inxcsr1 (under_run) bit is set by the usb fcu intst3, intst5, intst7 or intst9 is set to a 1 by the usb fcu when (in endpoint xout csr): ?a packet of data is successfully received (outxcsr0 - out_pkt_rdy is set by the usb fcu) ?outxcsr1 (over_run) bit is set by the usb fcu ?outxcsr4 (force_stall) bit is set by the usb fcu intst12 is set to a 1 by the usb fcu when an overrun or underrun condition occurs in any of the endpoints. intst13 is set to a 1 by the usb fcu when a usb reset signaling from the host is received. all internal register bits except this bit are reset to their default values when the usb reset is received. intst14 is set to a 1 by the usb fcu when the usb fcu is in the suspend state and non-idle signaling is received from d+/d-. intst15 is set to a 1 by the usb fcu when d+/d- are in the idle state for more than 3ms. figure 1.34: usb interrupt status register 1 usb interrupt status register 1 symbol address when reset usbis1 0302 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 function w r reserved must always be set to "0" intst0 intst2 intst3 intst4 intst5 intst6 intst7 usb endpoint 0 interrupt status flag usb endpoint 1 in interrupt status flag usb endpoint 1 out interrupt status flag usb endpoint 2 in interrupt status flag usb endpoint 2 out interrupt status flag usb endpoint 3 in interrupt status flag usb endpoint 3 out interrupt status flag 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0
1-53 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus figure 1.35: usb interrupt status register 2 2.18.4.6 clearing of the usb interrupt status registers the usb interrupt status register 1 and 2 are used to indicate pending interrupts for a given source. the usb fcu sets the interrupt status bits. the cpu writes a 1 to each status bit to clear it. because the usb function interrupt has multiple sources that can generate an interrupt, it is recommended that the user first read the two status registers and store them in variables then write back the same value for clearing all the existing interrupts that were pending when the status registers were read. this procedure pre- vents any interrupt that occurs after the status registers are read from being cleared by the write-back oper- ation. the cpu must read, then write both status registers, writing to status register 1 first and status register 2 second to guarantee proper operation. the upper three bits of the value written back to usbis2 should al- ways be 000 to prevent any of the usb reset, suspend and resume status flags from being cleared. the usb reset, suspend and resume status flags are contained in usbis2 along with the usb endpoint 4 in/out interrupt status flags and the usb overrun/underrun interrupts status flag. because the flags are not all sources for the same interrupt, use caution when clearing one or more of the flags to avoid inadvertently clearing other flags. the reset, suspend and resume status flags should be cleared individually by writing a byte value with at 1 only at the position corresponding to the flag to be cleared. the usb endpoint 4 in/ out interrupt status flags and the usb overrun/underrun interrupt status flag should be cleared as de- scribed in the preceding paragraph because they are sourced for the usb function interrupt. read-modify-write instructions, such as bclr and bset, should not be used to clear any of the interrupt status bits in usbis1 or usbis2. using these instructions could cause pending interrupts to be cleared with- out the firmwares knowledge. 2.18.4.7 the usb function interrupt enable registers 1 and 2 the usb function interrupt enable registers 1 and 2, shown in figure 1.36 and figure 1.37, are used to en- able the corresponding interrupt status conditions that can generate a usb function interrupt. when the bit to a corresponding interrupt condition is 0, that condition does not generate a usb function interrupt. when the bit is a 1, that condition can generate a usb function interrupt. at reset, all usb function interrupt status conditions are enabled. usb interrupt status register 2 symbol address when reset usbis2 0303 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 function w r reserved must always be set to "0" intst8 intst9 usb endpoint 4 in interrupt status flag usb endpoint 4 out interrupt status flag usb overrun/underrun interrupt status flag usb reset interrupt status flag usb resume signaling interrupt status flag usb suspend signaling interrupt status flag 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued 0 : no interrupt request issued 1 : interrupt request issued reserved intst12 intst13 intst14 intst15 0 0
1-54 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus figure 1.36: usb interrupt enable register 1 figure 1.37: usb interrupt enable register 2 usb interrupt enable register 1 symbol address when reset usbie1 0304 16 ff 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 function w r reserved must always be set to "1" inten0 inten2 inten3 inten4 inten5 inten6 inten7 usb endpoint 0 interrupt enable bit usb endpoint 1 in interrupt enable bit usb endpoint 1 out interrupt enable bit usb endpoint 2 in interrupt enable bit usb endpoint 2 out interrupt enable bit usb endpoint 3 in interrupt enable bit usb endpoint 3 out interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled 1 usb interrupt enable register 2 symbol address when reset usbie2 0305 16 33 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 function w r reserved must always be set to "0" inten8 inten9 usb endpoint 4 in interrupt enable bit usb endpoint 4 out interrupt enable bit usb overrun/underrun interrupt enable bit 0 : interrupt disabled 1 : interrupt enabled inten12 0 : interrupt disabled 1 : interrupt enabled 0 : interrupt disabled 1 : interrupt enabled reserved must always be set to "1" reserved must always be set to "0" 0 0 1 0 0
1-55 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus 2.18.4.8 usb frame number registers the usb frame number low register, shown in figure 1.38, contains the lower 8 bits of the 11-bit frame number received from the host. the usb frame number high register, shown in figure 1.39 contains the upper 3 bits of the 11-bit frame number received from the host. figure 1.38: usb frame number low register figure 1.39: usb frame number high register 2.18.4.9 usb iso control register the usb iso control register, shown in figure 1.40, contains two global bits, iso_upd and auto_fl for controlling endpoints 1-4 isochronous data transfer. when iso_upd = 0, a data packet in an endpoints in fifo is always ready to transmit upon receiving the next in_token from the host (with matched address and endpoint number) if the endpoints in_pkt_rdy is set. when iso_upd = 1 and the iso/toggle_init bit of the corresponding endpoints in csr is set, the in- ternal ready to transmit signal to the transmit control logic is not activated when the endpoints in_pkt_rdy is set. instead, it is activated when the next sof is received, this way, the data loaded in frame n is transmitted out in frame n+1. the iso_upd bit is a global bit for endpoints 1-4 and works with isochronous pipes only. when auto_fl = 1, iso_upd = 1, a particular in endpoints iso/toggle_init bit is set, and the in endpoints in_pkt_rdy = 1, the usb fcu detects a sof packet and the usb fcu automatically flushes the oldest packet from the in fifo. in this case, in_pkt_rdy = 1, indicates that two data packets are in the in fifo. because double buffering is a requirement for iso transfer, maxp must be set to less than or equal to 1/2 of the fifo size. figure 1.40: usb iso control register usb frame number low register symbol address when reset usbsofl 0306 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 fn0 to fn7 function w r lower 8 bits of the 11-bit frame number issued with a sof token x usb frame number high register symbol address when reset usbsofh 0307 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 fn8 fn9 fn10 function w r upper 3 bits of the 11-bit frame number issued with a sof token reserved must always be set to "0" x x 0 0 0 0 0 usb iso control register symbol address when reset usbisoc 0308 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 function w r reserved must always be set to "0" auto_fl iso_upd auto_flush bit iso_update bit 0 : hardware auto fifo flush diabled 1 : hardware auto fifo flush enabled 0 : iso_update disabled 1 : iso_update enabled 0 0 0 0 0 0
1-56 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus 2.18.4.10 usb dmax request registers the usb dmax request registers, shown in figure 1.41 and figure 1.42, are used to select which usb end- point x fifo read/write requests are selected as the dmac channel 0 or channel 1 request source. the usb dma0 (dma1) request register should have only one bit set at any given time. when multiple bits are set, no request is selected. figure 1.41: usb dma0 request register figure 1.42: usb dma1 request register 2.18.4.11 usb endpoint enable register the usb endpoint enable register, shown in figure 1.43, is used to enable/disable an individual endpoint. endpoint 0 is always enabled and cannot be disabled by firmware. all endpoints are enabled after reset. figure 1.43: usb endpoint enable register usb dma0 request register symbol address when reset usbsar0 0309 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 function w r dma0r0 dma0r1 dma0r2 dma0r3 dma0r4 dma0r5 dma0r6 dma0r7 endpoint 1 in fifo write request selection bit endpoint 2 in fifo write request selection bit endpoint 3 in fifo write request selection bit endpoint 4 in fifo write request selection bit endpoint 1 out fifo read request selection bit endpoint 2 out fifo read request selection bit endpoint 3 out fifo read request selection bit endpoint 4 out fifo read request selection bit 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 : not selected 1 : selected usb dma1 request register symbol address when reset usbsar1 030a 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 function w r dma1r0 dma1r1 dma1r2 dma1r3 dma1r4 dma1r5 dma1r6 dma1r7 endpoint 1 in fifo write request selection bit endpoint 2 in fifo write request selection bit endpoint 3 in fifo write request selection bit endpoint 4 in fifo write request selection bit endpoint 1 out fifo read request selection bit endpoint 2 out fifo read request selection bit endpoint 3 out fifo read request selection bit endpoint 4 out fifo read request selection bit 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 : not selected 1 : selected usb endpoint enable register symbol address when reset usbepen 030b 16 ff 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 function w r ep1_out ep1_in ep2_out ep2_in ep3_out ep3_in ep4_out ep4_in endpoint 1out fifo enable bit endpoint 1 in fifo enable bit endpoint 2out fifo enable bit endpoint 2 in fifo enable bit endpoint 3 out fifo enable bit endpoint 3 in fifo enable bit endpoint 4 out fifo enable bit endpoint 4 in fifo enable bit 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 : disabled 1 : enabled
1-57 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus 2.18.4.12 endpoint 0 csr (control and status register) the endpoint 0 csr (control and status register), shown in figure 1.44 contains the control and status in- formation of endpoint 0. ?ep0csr0 (out_pkt_rdy): the usb fcu sets this bit to a 1 after it receives a valid setup/out token from the host. the cpu clears this bit after unloading the packet from the fifo by writing a 1 to ep0csr6. the cpu should not clear the out_pkt_rdy bit before it finishes decoding the host request. when ep0csr2 (send_stall) needs to be set (because the cpu decodes an invalid or unsupported request) a 1 should be written to ep0csr6 and ep0csr2 at the same time using the same instruction. ? ep0csr1 (in_pkt_rdy): the cpu writes a 1 to this bit after it finishes writing a packet of data to the endpoint 0 fifo. the usb fcu clears this bit after the packet is successfully transmitted to the host, or the ep0csr5 (setup_end) bit is set. ? ep0csr2 (send_stall): the cpu writes a 1 to this bit when it decodes an invalid or unsupported standard device request from the host. when the out-pkt_rdy bit is a 1 at the time the cpu wants to set the send_stall bit to a 1, the cpu must also set serviced_out_pkt_rdy to a 1 to clear the out-pkt_rdy at the same time as set- ting the send_stall bit. the usb fcu returns a stall handshake for all subsequent in/out transactions (during control transfer data or status stages) while this bit is set. the cpu writes a 0 to clear it after it re- ceives a new setup packet. it is up to the firmware to decide what setup packet should lead the clearing of the send_stall bit. ? ep0csr3 (data_end): the cpu writes a 1 to this bit when it writes (in data phase) or reads (out data phase) the last packet of data to or from the fifo. the cpu sets this bit at the same time as it sets the last in_pkt_rdy bit or sets the last serviced_out_pkt_rdy bit.this bit indicates to the usb fcu that the specific amount of data in the setup phase is transferred. the usb fcu advances to the status phase once this bit is set. when the status phase completes, the usb fcu clears this bit. when this bit is set to a 1, and the host requests or sends more data, the usb fcu returns a stall handshake and terminates the current control transfer. ? ep0csr4 (force_stall): the usb fcu sets this bit to a 1 to report an error status when one of the following occur: ? host sends an in token in the absence of a setup stage ? host sends a bad data toggle in the status stage, (i.e. data0 is used) ? host sends a bad data toggle in the setup stage, (i.e. data1 is used) ? host request more data than specified in the setup state, (i.e. in token comes after data_end bit is set) ? host sends more data than specified in the setup state, (i.e. out token comes after data_end bit is set) ? host sends larger data packet than maxp size all of the conditions stated (except bad data toggle in the setup stage) cause the device to send a stall handshake for the current in/out transaction. for the bad data toggle in the setup state, the device sends ack for the setup stage and then sends stall for the next in/out transaction. a stall handshake caused by the above listed conditions lasts for one transaction and terminates the ongoing control transfer. any packet after the stall handshake will be seen as the beginning of a new control transfer. the cpu writes a 0 to clear the force_stall status bit. ? ep0csr5 (setup_end): the usb fcu sets this bit to a 1 if a control transfer has ended before the specific length of data is trans- ferred during the data phase (status phase starts before data_end bit is set) or a control transfer has ended before a new setup has arrived and before successfully completing the status phase. the cpu clears this bit by writing a 1 to in0csr7. once the cpu detects the setup_end bit as set, it should stop accessing the fifo to service the previous setup transaction. if the setup_end is caused by the reception of the set- up packet prior to the end of the current control transfer, the out_pkt_rdy bit is set once the reception of the setup packet has completed (without errors). after the out_pkt_rdy bit is set, the new setup packet
1-58 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus data will be in the fifo. for this case, because the setup_end bit is set near the beginning of the packet when the setup pid is encountered and the out_pkt_rdy bit is set at the end of the packet, the value read from ep0in_csr in the usb functional interrupt routine may only show that the setup_end bit as 1 instead of both the setup_end and out_pkt_rdy bits. ? ep0csr6 and ep0csr7: these bits are used to clear ep0csr0 and ep0csr5 respectively. writing a 1 to these bits clears the cor- responding register bit. figure 1.44: usb endpoint 0 csr 2.18.4.13 usb endpoint 0 maxp register the usb endpoint 0 maxp register, shown in figure 1.45, indicates the maximum packet size (maxp) of endpoint 0 in/out packet. the default value for endpoint 0 maxp is 8 bytes. figure 1.45: usb endpoint 0 maxp usb endpoint 0 control and status register (note 5) symbol address when reset ep0cs 0311 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 function w r ep0csr0 ep0csr1 epocsr2 epocsr3 ep0csr4 epocsr5 ep0csr6 epocsr7 out_pkt_rdy flag in_pkt_rdy bit send_stall bit data_end bit force_stall flag setup_end flag serviced_out_pky_rdy bit serviced_setup_end bit 0 : not ready 1 : ready 0 : not ready 1 : ready 0 : no action 1 : stall endpoint 0 by cpu 0 : no action 1 : last packet transferred from/to fifo 0 : no action 1 : stall endpoint 0 by usb fcu 0 : no action 1 : control transfer ended before specific length of data transferred during data phase 0 : no change 1 : clear the out_pkt_rdy bit (epocsr0) 0 : no change 1 : clear the stup-end bit (ep0csr5) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 note 1: read only note 2: write "1" only or read note 3: write "0" only or read note 4: write only - read "0" note 5: refer to section 5.5 "programming notes" for this register note 1 note 1 note 2 note 3 note 2 note 4 note 4 usb endpoint 0 maxp register symbol address when reset ep0mp 0313 16 08 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 ep0mxp0 to ep0mxp5 function w r maximum packet size (maxp) of endpoint 0 in/out packet reserved must always be set to "0" 0 0
1-59 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus 2.18.4.14 usb endpoint 0 out wrt cnt register the usb endpoint 0 out wrt cnt register, shown in figure 1.46, contains the number of bytes of the cur- rent data set in the out fifo. the usb fcu sets the value in the write count register after having success- fully received a packet of data from the host. the cpu reads the register to determine the number of bytes to be read from the fifo. figure 1.46: usb endpoint 0 out wrt cnt 2.18.4.15 usb endpoint x in csr (control & status register) the usb endpoint x in csr (control and status register), shown in figure 1.47, contains control and status information of the respective in endpoint 1-4. ? inxcsr0 (in_pkt_rdy) and inxcsr5 (tx_fifo_not_empty): these two bits are for in fifo status when in read operation (see in (transmit) fifo operation for details). the cpu writes a 1 to the inxcsr0 bit to inform the usb fcu that a packet of data is written to the fifo. the usb fcu updates the pointers up on this bit set. the usb fcu also updates the pointers upon a packet of data successfully sent to the host. when the pointer updates are completed, the in fifo status is shown on inxcsr0 and inxcsr5 bits for the cpu to read. the cpu must allow at least one wait state between writ- ing and reading these bits for proper fifo status. ? inxcsr1 (under_run): this bit is used in iso mode only to indicate to the cpu that a fifo underrun has occurred. the usb fcu sets this bit to a 1 at the beginning of an in token if no data packet is in the fifo. setting this bit causes the inst12 bit of the interrupt status register 2 to set. the cpu writes a 0 to clear this bit. ? inxcsr2 (send_stall): the cpu writes a 1 to this bit when the endpoint is stalled (transmitter halt). the usb fcu returns a stall handshake while this bit is set. the cpu writes a 0 to clear this bit. ? inxcsr3 (iso/toggle_init): when the endpoint is used for isochronous data transfer, the cpu sets this bit to a 1 for the entire duration of the isochronous transfer. with the iso bit set to a 1, the device uses data0 as the pid for all packets sent back to the host. when the endpoint is required to initialize the data toggle, this set/reset of the toggle_init bit method as- sumes that there is no activity in transaction to the respective endpoint on the bus at the time the initialization process is ongoing. set/reset of the toggle_init bit is performed only when an endpoint experiences a con- figuration event. ? inxcsr4 (intpt): the cpu writes a 1 to this bit to initialize this endpoint as a status change endpoint for in transactions. this bit is set only when the corresponding endpoint is to be used to communicate rate feedback information (see chapter. in (transmit) fifos for details). ? inxcsr5 (tx_fifo_not_empty): the usb fcu sets this bit to a 1 when there is at least one data packet in the in fifo. this bit, in conjunction with in_pkt_rdy bit, provides the transmit in fifo status information (see in (transmit) fifo for details). ? inxcsr6 (flush): usb endpoint 0 out write count register symbol address when reset ep0wc 0315 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 w_cnt0 to w_cnt4 function w r receive byte count reserved must always be set to "0" x x 0 0 0
1-60 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus the cpu writes a 1 to this bit to flush the in fifo. when there is one packet in the in fifo, a flush causes the in fifo to be empty. when there are two packets in the in fifo, a flush causes the older packet to be flushed out from the in fifo. setting the inxcsr6 (flush) bit during transmission could produce unpredict- able results. ?inxcsr7 (auto_set): when the cpu sets this bit to a 1, the in_pkt_rdy bit is set automatically by the usb fcu after the number of bytes of data equal to the maximum packet size (maxp) is written into the in fifo (see in (transmit) fifo operation for details). figure 1.47: usb endpoint x in csr 2.18.4.16 usb endpoint x out control and status register the usb endpoint x out csr (control and status register), shown in figure 1.48 contains control and sta- tus information of the respective out endpoint 1-4. ? outxcsr0 (out _pkt_rdy): the outxcsr0 bit for the out fifo status (see out (receive) fifos for details). the usb fcu sets this bit to a 1 and updates the fifo pointers after a data packet has been successfully received from the host. the cpu writes a 0 to this bit to inform the usb fcu that a data packet has been unloaded. the usb fcu updates the fifo pointers when this occurs. the cpu must allow at least one clock cycle between writing and reading bit outxcsr0. ? outxxcsr1 (over_run): this bit is used in iso mode only to indicate to the cpu that a fifo overrun has occurred. the usb fcu sets this bit to a 1 at the beginning of an out token when two data packets are already present in the fifo. set- ting this bit causes the inst12 bit of the interrupt status register 2 to set. the cpu writes a 0 to clear outxcsr1. ? outxcsr2 (send_stall): the cpu writes a 1 to this bit when the endpoint is stalled. the usb fcu returns a stall handshake while this bit is set. the cpu writes a 0 to clear this bit. ? outxcsr3 (iso/toggle_init): when the endpoint is used for isochronous data transfer, the cpu sets this bit to a 1 for the entire duration of the isochronous transfer. with the iso/toggle_init bit set to a 1, the device accepts either data0 or data1 for the pid sent by the host. usb endpoint x in control and status register (note 5) symbol address when reset epiics (i= 1-4) 0319 16, 0321 16, 0329 16, 0331 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 function w r inxcsr0 inxcsr1 inxcsr2 inxcsr3 inxcsr4 inxcsr5 inxcsr6 inxcsr7 in_pkt_rdy bit under_run flag send_stall bit iso bit intpt tx_not_ept flag flush bit auto_set bit 0 : not ready 1 : ready 0 : no fifo underrun 1 : fifo underrun has occured 0 : no action 1 : stall in endpoint x by cpu 0 : select non-isochronous transfer 1 : select isochronous transfer 0 : select non-rate feedback interrupt transfer 1 : select rate feedback interrupt transfer 0 : transmit fifo is empty 1 : transmit fifo is not empty 0 : no action 1 : flush the fifo 0 : auto-set disabled 1 : auto-set enabled 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 note 1: write "1" only or read note 2: write "0" only or read note 3: read only note 4: write only - read "0" note 5: refer to section 5.5 "programming notes" for this register note 1 note 2 note 3 note 4
1-61 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus when endpoint is required to initialize the data toggle sequence bit (i.e. reset to data0 for the next data pack- et), the cpu sets this bit to a 1 and then resets it to a 0 to initialize the respective endpoints data toggle. successful initialization of the data toggle sequence bit can only be guaranteed if no active out transaction to the respective endpoint is ongoing when the initialization process is taking place. set/reset of the iso/ toggle_init bit should only be performed when an endpoint experiences a configuration event. ? outxcsr4 (force_stall): the usb fcu sets this bit to a 1 when the host sends out a larger data packet than the maxp size. the usb fcu returns a stall handshake while this bit is set. the cpu writes a 0 to clear this bit. ? outxcsr5 (data_err): the usb fcu sets this bit to a 1 to indicate that a crc error or a bit stuffing error was received in an iso packet. the cpu writes a 0 to clear this bit. ? outxcsr6 (flush): the cpu writes a 1 to this to flush the out fifo. when there is one packet in the out fifo, a flush causes the out fifo to be empty. when there are two packets in the out fifo, a flush causes the older packet to be flushed out from the out fifo. setting the outxcsr6 (flush) bit during reception could produce un- predictable results. ? outxcsr7 (auto_clr): when the cpu sets this bit to a 1, the out_pkt_rdy bit is cleared automatically by the usb fcu after the number of bytes of data equal to the maximum packet size (maxp) is unloaded from the out fifo (see out (receive) fifo for details). figure 1.48: usb endpoint x out csr 2.18.4.17 usb endpoint x in maxp register the usb endpoint x in maxp register, shown in figure 1.49, indicates the maximum packet size (maxp) of an endpoint x in packet. the default values for endpoints 1-4 are 0 bytes. the setting of this register also affects the configuration of single/dual packet operation. when maxp > 1/2 of the fifo size, single packet mode is set. when maxp <= 1/2 of the fifo size, dual packet mode is set. figure 1.49: usb endpoint x in maxp usb endpoint x out control and status register (note 3) symbol address when reset epiocs (i = 1-4) 031a 16, 0322 16, 032a 16, 0332 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 function w r outxcsr0 outxcsr1 outxcsr2 outxcsr3 outxcsr4 outxcsr5 outxcsr6 outxcsr7 out_pkt_rdy flag over_run flag send_stall bit iso bit force-stall flag data-err flag flush bit auto_clr bit 0 : not ready 1 : ready 0 : no fifo overrun 1 : fifo overrun occured 0 : no action 1 : stall out endpoint x by cpu 0 : select non-isochronous transfer 1 : select isochronous transfer 0 : no action 1 : stall endpoint x by the usb fcu 0 : no error 1 : crc or bit stuffing error received in iso packet 0 : no action 1 : flush the fifo 0 : auto-clr disabled 1 : auto-clr enabled 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 note 1: write "0" only or read note 2: write only - read "0" note 3: refer to section 5.5 "programming notes" for this register note 1 note 2 note 1 note 1 note 1 usb endpoint x in maxp register symbol address when reset epiimp (i = 1-4) 031b 16, 0323 16, 032b 16, 0333 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 imaxp0 to imaxp7 function w r maximum packet size (maxp) of endpoint x in packet. for endpoints that support smaller fifo size, unused bits are not implemented, (always write "0" to those bits).
1-62 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change universal serial bus 2.18.4.18 usb endpoint x out maxp register the usb endpoint x out maxp register, shown in figure 1.50, indicates the maximum packet size (maxp) of an endpoint x out packet. the default values for endpoints 1-4 are 0 bytes. the setting of this register also affects the configuration of single/dual packet operation. when maxp > 1/2 of the fifo size, single packet is set. when maxp <= 1/2 of the fifo size, dual packet mode is set. figure 1.50: usb endpoint x out maxp 2.18.4.19 usb endpoint x out wrt cnt register the usb endpoint x out wrt cnt register, shown in figure 1.51, contains the number of bytes of the cur- rent data set in the out fifo. the usb fcu sets the value in the write count register after having success- fully received a packet of data from the host. the cpu reads the register to determine the number of bytes to be read from the fifo. figure 1.51: usb endpoint x out wrt cnt 2.18.4.20 usb endpoint x fifo register the usb endpoint x fifo register, shown in figure 1.52 is the usb in (transmit) and out (receive) fifo data register. the cpu writes data to this register for the corresponding endpoint in fifo and reads data from this register for the corresponding endpoint out fifo. figure 1.52: usb endpoint x fifo register usb endpoint x out maxp register symbol address when reset epiomp (i = 1-4) 031c 16, 0324 16, 032c 16, 0334 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 omaxp0 to omaxp7 function w r maximum packet size (maxp) of endpoint x out packet. for endpoints that support smaller fifo size, unused bits are not implemented, (always write "0" to those bits). usb endpoint x out write count register symbol address when reset epiwc (i = 1-4) 031d 16, 0325 16, 032d 16, 0335 16 00 16 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 w_cnt0 to w_cnt7 function w r receive byte count x usb endpoint x fifo register symbol address when reset epi (i = 0-4) 0338 16, 0339 16, 033a 16, 033b 16, 033c 16 indeterminate bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 data_0 to data_7 function w r endpoint x in/out fifo register x
1-63 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change dmac 2.19 dmac this microcomputer has two dmac (direct memory access controller) channels that allow data to be sent to memory without using the cpu.table 1.14 shows the dmac specifications. figure 1.53 shows the block diagram of the dmac. figure 1.54, figure 1.55 and figure 1.56 show the registers used by the dmac. table 1.14: dmac speci?cations item speci?cation number of channels 2 (cycle steal method) transfer memory space ?from any sfr, ram, or rom address to a ?xed address ?from a ?xed address to any sfr or ram address ?from a ?xed address to a ?xed address (note that dma-related registers [0020 16 to 003f 16 ] cannot be accessed) maximum number of bytes transferred 128k bytes (with 16-bit transfers) or 64k bytes (with 8-bit transfers) dma request sources falling edge of int0 or int1 (int0 can be selected by dma0, int1 by dma1) timer a0 to timer a4 timer b0 to timer b1 uart0 transmission and reception uart1 transmission and reception uart2 transmission and reception a-d conversion complete usb function software triggers channel priority dma0 takes precedence if dma0 and dma1 requests are generated simultaneously transfer unit 8 bits or 16 bits transfer address direction forward/?xed (forward direction cannot be speci?ed for both source and destination simultaneously) transfer modes single transfer mode the dma enable bit is cleared and transfer ends when an under?ow occurs in the transfer counter. repeat transfer mode when an under?ow occurs in the transfer counter, the value in the transfer counter reload register is loaded into the transfer counter and the dma transfer is repeated dma interrupt request generation timing when an under?ow occurs in the transfer counter dma startup single transfer mode transfer starts when the dma is requested after 1 is written to the dma enable bit repeat transfer mode transfer starts when the dma is requested after 1 is written to the dma enable bit or after an under?ow occurs in the transfer counter dma shutdown when 0 is written to the dma enable bit when, in single transfer mode, an under?ow occurs in the transfer counter forward address pointer and reload timing for transfer counter when dma transfer starts, the value of whichever of the source or destination pointer that is set up as the forward pointer is loaded into the forward address pointer. the value in the transfer counter reload register is loaded into the transfer counter. writing to register registers speci?ed for forward direction transfer are always write-enabled. registers speci?ed for ?xed address transfer are write-enabled when the dma enable bit is 0. reading the register can be read at any time. however, when the dma enable bit is 1, reading the register sets up as the forward register is the same as reading the value of the forward address pointer.
1-64 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change dmac figure 1.53: block diagram of dmac figure 1.54: dmac register (1) data bus low-order bits dma latch high-order bits dma latch low-order bits dma0 source pointer sar0(20) dma0 destination pointer dar0 (20) dma0 forward address pointer (20) data bus high-order bits address bus dma1 destination pointer dar1 (20) dma1 source pointer sar1 (20) dma1 forward address pointer (20) dma0 transfer counter reload register tcr0 (16) dma0 transfer counter tcr0 (16) dma1 transfer counter reload register tcr1 (16) dma1 transfer counter tcr1 (16) (addresses 0029 16 , 0028 16 ) (addresses 0039 16 , 0038 16 ) (addresses 0022 16 to 0020 16 ) (addresses 0026 16 to 0024 16 ) (addresses 0032 16 to 0030 16 ) (addresses 0036 16 to 0034 16 ) note: pointer is incremented by a dma request. dmai request cause select register symbol address when reset dmisl (i=0,1) 03b8 16, 03ba 16 00 16 function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 dma request cause select bit dsel0 rw dsel1 dsel2 dsel3 nothing is assigned. these bits can neither be set nor reset. when read, the value of these bits is ?? software dma request bit if software trigger is selected, a dma request is generated by setting this bit to ?? (when read, the value of this bit is always ?? dsr b3 b2 b1 b0 0 0 0 0 : falling edge of int0 / int1 pin (note1) 0 0 0 1 : software trigger 0 0 1 0 : timer a0 0 0 1 1 : timer a1 0 1 0 0 : timer a2 0 1 0 1 : timer a3 0 1 1 0 : timer a4 0 1 1 1 : timer b0 1 0 0 0 : timer b1 1 0 0 1 : usb0/usb1 (note 3) 1 0 1 0 : uart0 transmit 1 0 1 1 : uart0 receive 1 1 0 0 : uart2 transmit 1 1 0 1 : uart2 receive 1 1 1 0 : a-d conversion 1 1 1 1 : uart1 transmit / uart1 receive (note 2) bit name note 1: address 03b8 16 is for int0, 03ba 16 is for int1. note 2: address 03b8 16 is for uart1 transmit, 03ba 16 is for uart1 receive. note 3: address 03b8 16 is for usb0, 03ba 16 is for usb1.
1-65 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change dmac figure 1.55: dmac register (2) figure 1.56: dmac register (3) dmai control register symbol address when reset dmicon(i=0,1) 002c 16 , 003c 16 00000x00 2 bit name function bit symbol transfer unit bit select bit b7 b6 b5 b4 b3 b2 b1 b0 0 : 16 bits 1 : 8 bits dmbit rw dmasl dmas dmae repeat transfer mode select bit 0 : single transfer 1 : repeat transfer dma request bit (note 1) 0 : dma not requested 1 : dma requested 0 : disabled 1 : enabled 0 : fixed 1 : forward dma enable bit source address direction select bit (note 3) destination address direction select bit (note 3) 0 : fixed 1 : forward dsd dad nothing is assigned. these bits can neither be set nor reset. when read, the value of these bits is ?? note 1: dma request can be cleared by resetting the bit. note 2: this bit can only be set to ?? note 3: source address direction select bit and destination address direction select bit cannot be set to ??simultaneously. (note 2) b7 b0 b7 b0 (b8) (b15) function rw transfer counter set a value one less than the transfer count symbol address when reset tcr0 0029 16 , 0028 16 indeterminate tcr1 0039 16 , 0038 16 indeterminate dmai transfer counter (i = 0, 1) transfer count specification 0000 16 to ffff 16 b7 (b23) b3 b0 b7 b0 b7 b0 (b8) (b16)(b15) (b19) function rw source pointer stores the source address symbol address when reset sar0 0022 16 to 0020 16 indeterminate sar1 0032 16 to 0030 16 indeterminate dmai source pointer (i = 0, 1) transfer count specification 00000 16 to fffff 16 nothing is assigned. these bits can neither be set nor reset. when read, the value of these bits is ?? symbol address when reset dar0 0026 16 to 0024 16 indeterminate dar1 0036 16 to 0034 16 indeterminate b3 b0 b7 b0 b7 b0 (b8) (b15) (b16) (b19) function rw destination pointer stores the destination address dmai destination pointer (i = 0, 1) transfer count specification 00000 16 to fffff 16 b7 (b23) nothing is assigned. these bits can neither be set nor reset. when read, the value of these bits is ??
1-66 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change dmac 2.19.1 transfer cycle the transfer cycle consists of the bus cycle in which data is read from memory or from the sfr area (source read) and the bus cycle in which the data is written to memory or to the sfr area (destination write). the number of read and write bus cycles depends on the source and destination addresses and the software waits are inserted. 2.19.1.1 effect of source and destination addresses when 16-bit data is transferred on a 16-bit data bus, and the source and destination both start at odd address- es, there is one more source read cycle and destination write cycle than when the source and destination both start at even addresses. 2.19.2 dmac transfer cycles any combination of even or odd transfer read and write addresses is possible. table 1.15 show the number of dmac transfer cycles. table 1.16 shows the corresponding coefficient values. figure 1.57 shows an example of the transfer cycle for a source read. the number of dmac transfer cycles can be calculated as follows: number of transfer cycles per transfer unit = number of read cycles x j + number of write cycles x k table 1.15: number of dmac transfer cycles transfer unit access address single-chip mode number of read cycles number of write cycles 8-bit transfers (dmbit=1) even 1 1 odd 1 1 16-bit transfers (dmbit=0) even 1 1 odd 2 2 table 1.16: coef?cients j,k internal memory internal rom/ ram no wait internal rom/ ram with wait sfr area 122
1-67 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change dmac figure 1.57: example of the transfer cycle for a source read clkout address bus data bus cpu use cpu use cpu use cpu use source source destination destination dummy cycle dummy cycle (1) 8-bit transfers 16-bit transfers from even address and the source address is even. clkout address bus rd signal wr signal data bus cpu use cpu use cpu use cpu use source source destination destination dummy cycle dummy cycle (3) one wait is inserted into the source read under the conditions in (1) clkout address bus data bus cpu use cpu use cpu use cpu use source source destination destination dummy cycle dummy cycle source + 1 source + 1 (2) 16-bit transfers and the source address is odd transferring 16-bit data on an 8-bit data bus (in this case, there are two destination write cycles). clkout address bus rd signal wr signal data bus cpu use cpu use cpu use cpu use source source destination destination dummy cycle dummy cycle source + 1 source + 1 (4) one wait is inserted into the source read under the conditions in (2) (when 16-bit data is transferred on an 8-bit data bus, there are two destination write cycles). note: the same timing changes occur with the respective conditions at the destination as at the source.
1-68 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timers 2.20 timers there are eight 16-bit timers. these timers can be classified by function into timers a (five) and timers b (three). all these timers function independently. figure 1.58 shows the block diagram of timers a and b. figure 1.58: timer a and timer b block diagram timer a3 interrupt timer a4 interrupt timer a1 interrupt timer a2 interrupt timer a0 interrupt timer b1 interrupt ? timer mode ? one-shot mode ? pwm mode ? timer mode ? one-shot mode ? pwm mode ? timer mode ? one-shot mode ? pwm mode ? timer mode ? one-shot mode ? pwm mode ? timer mode ? one-shot mode ? pwm mode ? event counter mode ? event counter mode ? event counter mode ? event counter mode ? event counter mode ta0 in ta1 in ta2 in ta3 in ta4 in timer a0 timer a1 timer a2 timer a3 timer a4 f 1 f 8 f 32 noise filter noise filter noise filter noise filter noise filter 1/8 1/4 f 1 f 8 f 32 x in timer b0 interrupt ? timer mode ? timer mode ? timer mode timer b0 timer b1 timer b2 timer b2 interrupt
1-69 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timer a 2.21 timer a figure 1.59, figure 1.60,figure 1.61, and figure 1.62 show the timer a-related registers. except in event counter mode, timers a0 through a4 all have the same function. use the timer ai mode register (i = 0 to 4) bits 0 and 1 to choose the desired mode. timer a has the four operation modes listed as follows: ? timer mode: the timer counts an internal count source. ? event counter mode: the timer counts pulses from an external source or a timer over flow. ? one-shot timer mode: the timer stops counting when the count reaches 0000 16 . ? pulse width modulation (pwm) mode: the timer outputs pulses of a given width. figure 1.59: block diagram of timer a figure 1.60: timer a related registers (1) tai addresses taj tak timer a0 0387 16 0386 16 timer a4 timer a1 timer a1 0389 16 0388 16 timer a0 timer a2 timer a2 038b 16 038a 16 timer a1 timer a3 timer a3 038d 16 038c 16 timer a2 timer a4 timer a4 038f 16 038e 16 timer a3 timer a0 count start flag (address 0380 16 ) up count/down count always down count except in event counter mode reload register (16) counter (16) low-order 8 bits high-order 8 bits clock source selection ? timer (gate function) ? timer ? one shot ? pwm f 1 f 8 f 32 external trigger tai in (i = 0 to 4) tb2 overflow ? event counter clock selection taj overflow (j = i C 1. note, however, that j = 4 when i = 0) pulse output toggle flip-flop tai out (i = 0 to 4) data bus low-order bits data bus high-order bits up/down flag down count (address 0384 16 ) tak overflow (k = i + 1. note, however, that k = 0 when i = 4) polarity selection timer ai mode register symbol address when reset taimr(i=0 to 4) 0396 16 to 039a 16 00 16 bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 operation mode select bit 0 0 : timer mode 0 1 : event counter mode 1 0 : one-shot timer mode 1 1 : pulse width modulation (pwm) mode b1 b0 tmod1 tmod0 mr0 mr2 mr1 mr3 tck1 tck0 count source select bit function varies with each operation mode function varies with each operation mode
1-70 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timer a figure 1.61: timer a-related registers (2) timer a4 up/down flag timer a3 up/down flag timer a2 up/down flag timer a1 up/down flag timer a0 up/down flag timer a2 two-phase pulse signal processing select bit timer a3 two-phase pulse signal processing select bit timer a4 two-phase pulse signal processing select bit symbol address when reset udf 0384 16 00 16 ta4p ta3p ta2p up/down flag bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 ta4ud ta3ud ta2ud ta1ud ta0ud 0 : down count 1 : up count this specification becomes valid when the up/down flag content is selected for up/down switching cause 0 : two-phase pulse signal processing disabled 1 : two-phase pulse signal processing enabled when not using the two-phase pulse signal processing function, set the select bit to ? symbol address when reset tabsr 0380 16 00 16 count start flag bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 timer b2 count start flag timer b1 count start flag timer b0 count start flag timer a4 count start flag timer a3 count start flag timer a2 count start flag timer a1 count start flag timer a0 count start flag 0 : stops counting 1 : starts counting tb2s tb1s tb0s ta4s ta3s ta2s ta1s ta0s symbol address when reset ta0 0387 16 ,0386 16 indeterminate ta1 0389 16 ,0388 16 indeterminate ta2 038b 16 ,038a 16 indeterminate ta3 038d 16 ,038c 16 indeterminate ta4 038f 16 ,038e 16 indeterminate b7 b0 b7 b0 (b15) (b8) timer ai register (note) w r timer mode 0000 16 to ffff 16 counts an internal count source function values that can be set event counter mode 0000 16 to ffff 16 counts pulses from an external source or timer overflow one-shot timer mode 0000 16 to ffff 16 counts a one shot width pulse width modulation mode (16-bit pwm) functions as a 16-bit pulse width modulator pulse width modulation mode (8-bit pwm) timer low-order address functions as an 8-bit prescaler and high-order address functions as an 8-bit pulse width modulator 00 16 to fe 16 (both high-order and low-order addresses) 0000 16 to fffe 16 note: read and write data in 16-bit units.
1-71 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timer a figure 1.62: timer a-related registers (3) ta1tgl symbol address when reset trgsr 0383 16 00 16 timer a1 event/trigger select bit 0 0 : input on ta1 in is selected (note) 0 1 : tb2 overflow is selected 1 0 : ta0 overflow is selected 1 1 : ta2 overflow is selected trigger select register bit name function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 0 0 : input on ta2 in is selected (note) 0 1 : tb2 overflow is selected 1 0 : ta1 overflow is selected 1 1 : ta3 overflow is selected 0 0 : input on ta3 in is selected (note) 0 1 : tb2 overflow is selected 1 0 : ta2 overflow is selected 1 1 : ta4 overflow is selected 0 0 : input on ta4 in is selected (note) 0 1 : tb2 overflow is selected 1 0 : ta3 overflow is selected 1 1 : ta0 overflow is selected timer a2 event/trigger select bit timer a3 event/trigger select bit timer a4 event/trigger select bit w r ta1tgh ta2tgl ta2tgh ta3tgl ta3tgh ta4tgl ta4tgh b1 b0 b3 b2 b5 b4 b7 b6 note: set the corresponding port direction register to 0 . ta1os ta2os ta0os one-shot start flag symbol address when reset onsf 0382 16 00x00000 2 timer a0 one-shot start flag timer a1 one-shot start flag timer a2 one-shot start flag timer a3 one-shot start flag timer a4 one-shot start flag ta3os ta4os bit name function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 nothing is assigned. this bit can neither be set nor reset. when read, its content is indeterminate. ta0tgl ta0tgh 0 0 : input on ta0 in is selected (note) 0 1 : tb2 overflow is selected 1 0 : ta4 overflow is selected 1 1 : ta1 overflow is selected timer a0 event/trigger select bit b7 b6 note: set the corresponding port direction register to 0 . w r 1 : timer start when read, the value is 0 a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
1-72 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timer a 2.21.1 timer mode in this mode, the timer counts an internally generated count source. see table 1.17 below. figure 1.63 shows the timer ai mode register in timer mode. figure 1.63: timer ai mode register in timer mode table 1.17: speci?cations of timer mode item speci?cation count source f1, f8, f32 count operation ? down count ? when the timer under?ows, it loads the reload register contents before continuing counting divide ratio 1/(n+1) n: set value count start condition count start ?ag is set (= 1) count stop condition count start ?ag is reset (= 0) interrupt request generation timing when the timer under?ows taiin pin function programmable i/o port or gate input taiout pin function programmable i/o port or pulse output read from timer count value can be read out by reading timer ai register write to timer ? when counting is stopped and a value is written to timer ai register, it is written to both reload register and counter ? when counting is in progress and a value is written to timer ai register, it is written only to reload register (to be transferred to counter at the next reload time) select function ? gate function counting can be started and stopped by taiin pins input signal ? pulse output function each time the timer under?ows, the taiout pins polarity is reversed note 1: the settings of the corresponding port register and port direction register are invalid. note 2: the bit can be 0 or 1. note 3: set the corresponding port direction register to 0. timer ai mode register symbol address when reset taimr(i=0 to 4) 0396 16 to 039a 16 00 16 bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 operation mode select bit 0 0 : timer mode b1 b0 tmod1 tmod0 mr0 pulse output function select bit 0 : pulse is not output (ta iout pin is a normal port pin) 1 : pulse is output (note 1) (ta iout pin is a pulse output pin) gate function select bit 0 x (note 2) : gate function not available (tai in pin is a normal port pin) 1 0 : timer counts only when ta iin pin is held l (note 3) 1 1 : timer counts only when ta iin pin is held h (note 3) b4 b3 mr2 mr1 mr3 0 (must always be fixed to 0 in timer mode) 0 0 : f 1 0 1 : f 8 1 0 : f 32 1 1 : reserved b7 b6 tck1 tck0 count source select bit 00 0
1-73 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timer a 2.21.2 event counter mode in this mode, the timer counts an external signal or an internal timers overflow. timers a0 and a1 can count a single-phase external signal. timers a2, a3, and a4 can count a single-phase and a two-phase external signal. table 1.18 lists the timer specifications when counting a single-phase external signal. figure 1.64 shows timer ai mode register in event counter mode, single-phase signal. table 1.18: timer speci?cation in event counter mode (when not processing two-phase pulse signal) item speci?cation count source ?external signals input to taiin pin (effective edge can be selected by software ?tb2 over?ow, taj over?ow count operation ?up count or down count can be selected by external signal or software ?when the timer over?ows or under?ows, it loads from the reload register contents before continuing counting. (however, this does not apply when the free-run function is selected.) divide ratio 1/ (ffff 16 - n+1) for up count 1/ (n + 1) for down count n: set value count start condition count start ?ag is set (=1) count stop condition count start ?ag is reset (=0) interrupt request generation timing timer over?ows or under?ows taiin pin function programmable i/o port or count source input taiout pin function programmable i/o port, pulse output, or up/down count select input read from timer count value can be read out by reading timer ai register write to timer ?when counting is stopped and a value is written to timer ai register, it is written to both reload register and counter ?when counting is in progress and a value is written to timer ai register, it is written to only reload register select function ?free-run count function when the timer over?ows or under?ows, the reload register content is not reloaded. ?pulse output function each time the timer over?ows, the taiout pins polarity is reversed
1-74 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timer a figure 1.64: timer ai mode register in event counter mode, single signal table 1.19 shows the timer speci?cation in event counter mode when processing two-phase signal with timers a2, a3, and a4. figure 1.65 shows timer ai mode register in event counter mode when processing two-phase signal. note 1: in event counter mode, the count source is selected by the event / trigger select bit (addresses 0382 16 and 0383 16 ). note 2: the settings of the corresponding port register and port direction register are invalid. note 3: valid only when counting an external signal. note 4: when an l signal is input to the tai out pin, the downcount is activated. when h, the upcount is activated. set the corresponding port direction register to 0. note 5: this value can be indeterminate when the count starts. timer ai mode register symbol address when reset taimr(i = 0, 1) 0396 16 , 0397 16 00 16 w r b7 b6 b5 b4 b3 b2 b1 b0 operation mode select bit 0 1 : event counter mode (note 1) b1 b0 tmod0 mr0 pulse output function select bit 0 : pulse is not output (ta iout pin is a normal port pin) 1 : pulse is output (note 2) (ta iout pin is a pulse output pin) count polarity select bit (note 3) mr2 mr1 mr3 0 (must always be fixed to 0 in event counter mode) tck0 count operation type select bit 01 0 0 : counts external signal's falling edge 1 : counts external signal's rising edge up/down switching cause select bit 0 : up/down flag's content 1 : ta iout pin's input signal (note 4) 0 : reload type 1 : free-run type (note 5) bit symbol bit name function rw tck1 invalid in event counter mode can be 0 or 1 tmod1
1-75 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timer a table 1.19: timer speci?cation in even counter mode (when processing two-phase pulse signal with timers a2, a3, and a4) item speci?cation count source ?two-phase pulse signals input to taiin or taiout pin count operation ?up count or down count can be selected by two-phase pulse signal ?when the timer over?ows or under?ows, the reload register content is loaded and the timer starts over again (note 1) divide ratio 1/ (ffff 16 - n + 1) for up count 1/ (n+1) for down count n: set value count start condition count start ?ag is set (=1) count stop condition count start ?ag is reset (=0) interrupt request generation timing timer over?ow or under?ows ta i in pin function two-phase pulse input ta i out pin function two-phase pulse input read from timer count value can be read out by reading timer a2, a3, or a4 register writer to timer ?when counting is stopped and a value is written to timer a2, a3, or a4 register, it is written to both the reload register and counter ?when counting is in progress and a value is written to timer a2, a3, or a4 register, it is written to only reload register to be transferred to counter at the next reload time. select function ?normal processing operation the timer counts up rising edges or counts down falling edges on the tai in pin when input signal on the tai out pin is h ?multiply-by-4 processing operation if the phase relationship is such that the ta i in pin goes h when the input signal on the ta i out pin is h, the timer counts up rising and falling edges on the ta i out a nd t ai in pins. if the phase relationship is such that the t ai in pin goes l when the input signal on the ta i out pin is h, the timer counts down rising and falling edges on the ta i out and t ai in pins. note 1 this does not apply when the free-run function is selected. ta i out ta i in (i=2,3) up count up count up count down count down count down count count up all edges count down all edges count down all edges count up all edges ta i out t ai in (i=3,4)
1-76 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timer a figure 1.65: timer ai mode register in event counter mode, two-phase signal note 1: the settings of the corresponding port register and port direction register are invalid. note 2: this bit is valid when only counting an external signal. note 3: set the corresponding port direction register to 0. note 4: this bit is valid for the timer a3 mode register. for timer a2 and a4 mode registers, this bit can be 0 or 1. note 5: when performing two-phase pulse signal processing, make sure the two-phase pulse signal processing operation select bit (address 0384 16 ) is set to 1. also, always be sure to set the event/trigger select bit (addresses 0382 16 and 0383 16 ) to 00. note 6: this value can be indeterminate when the count starts. timer ai mode register (when not using two-phase pulse signal processing) symbol address when reset taimr(i = 2 to 4) 0398 16 to 039a 16 00 16 b7 b6 b5 b4 b3 b2 b1 b0 operation mode select bit 0 1 : event counter mode b1 b0 tmod1 tmod0 mr0 pulse output function select bit 0 : pulse is not output (tai out pin is a normal port pin) 1 : pulse is output (note 1) (tai out pin is a pulse output pin) count polarity select bit (note 2) mr2 mr1 mr3 0 : (must always be 0 in event counter mode) tck1 tck0 01 0 0 : counts external signal's falling edges 1 : counts external signal's rising edges up/down switching cause select bit 0 : up/down flag's content 1 : ta iout pin's input signal (note 3) bit symbol bit name function w r count operation type select bit two-phase pulse signal processing operation select bit (note 4)(note 5) 0 : reload type 1 : free-run type (note 6) 0 : normal processing operation 1 : multiply-by-4 processing operation note 1: this bit is valid for timer a3 mode register. for timer a2 and a4 mode registers, this bit can be 0 or 1. note 2: when performing two-phase pulse signal processing, make sure the two-phase pulse signal processing operation select bit (address 0384 16 ) is set to 1. also, always be sure to set the event/trigger select bit (addresses 0382 16 and 0383 16 ) to 00. note 3: this value can be indeterminate when the count starts. timer ai mode register (when using two-phase pulse signal processing) symbol address when reset taimr(i = 2 to 4) 0398 16 to 039a 16 00 16 b7 b6 b5 b4 b3 b2 b1 b0 operation mode select bit 0 1 : event counter mode b1 b0 tmod1 tmod0 mr0 0 (must always be 0 when using two-phase pulse signal processing) 0 (must always be 0 when using two-phase pulse signal processing) mr2 mr1 mr3 0 (must always be 0 when using two-phase pulse signal processing) tck1 tck0 01 0 1 (must always be 1 when using two-phase pulse signal processing) bit symbol bit name function w r count operation type select bit two-phase pulse processing operation select bit (note 1)(note 2) 0 : reload type 1 : free-run type (note 3) 0 : normal processing operation 1 : multiply-by-4 processing operation 0 0 1
1-77 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timer a 2.21.3 one-shot timer mode in this mode, the timer operates only once (see table 1.20 ). when a trigger occurs, the timer starts up and continues operating for a given period. figure 1.66 shows the timer ai mode register in one- shot mode. figure 1.66: timer ai mode register in one-shot mode table 1.20: timer speci?cations in one-shot timer mode item speci?cation count source f1, f8, f32 count operation ?the timer counts down ?when the count reaches 0000 16 , the timer stops counting after reloading a new count ? if a trigger occurs when counting, the timer reloads a new count and restarts counting divide ratio 1/n n: set value count start condition ? an external trigger is input ? the selected timer over?ows ? the one-shot start ?ag is set (= 1) count stop condition ? a new count is reloaded after the count has reached 0000 16 ? the count start ?ag is reset (= 0) interrupt request generation tim ing the count reaches 0000 16 taiin pin function programmable i/o port or trigger input taiout pin function programmable i/o port or pulse output read from timer when timer ai register is read, it indicates an indeterminate value write to timer ?when counting is stopped and a value is written to timer ai register, it is written to both reload register and counter ?when counting is in progress and a value is written to timer ai register, it is written to the reload register to be transferred to counter at next load time bit name timer ai mode register symbol address when reset taimr(i = 0 to 4) 0396 16 to 039a 16 00 16 function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 operation mode select bit 1 0 : one-shot timer mode b1 b0 tmod1 tmod0 mr0 pulse output function select bit 0 : pulse is not output (ta iout pin is a normal port pin) 1 : pulse is output (note 1) (tai out pin is a pulse output pin) mr2 mr1 mr3 0 (must always be ??in one-shot timer mode) 0 0 : f 1 0 1 : f 8 1 0 : f 32 1 1 : invalid b7 b6 tck1 tck0 count source select bit 10 0 0 : one-shot start flag is valid 1 : selected by event/trigger select register trigger select bit external trigger select bit (note 2) 0 : falling edge of tai in pin's input signal (note 3) 1 : rising edge of tai in pin's input signal (note 3) note 1: the settings of the corresponding port register and port direction register are invalid. note 2: valid only when the ta iin pin is selected by the event/trigger select bit (addresses 0382 16 and 0383 16 ). if timer overflow is selected, this bit can be ??or ?? note 3: set the corresponding port direction register to ?? w r
1-78 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timer a 2.21.4 pulse-width modulation (pwm) mode in this mode, the timer outputs pulses of a given width in succession (see table 1.21 ). in this mode, the counter functions as either a 16-bit pulse-width modulator or an 8-bit pulse-width modulator. figure 1.67 shows the timer ai mode register in pulse-width modulation mode.figure 1.68 shows the example of how a 16-bit pulse-width modulator operates. figure 1.69 shows the example of how an 8-bit pulse width modulator operates. figure 1.67: timer ai mode register in pulse-width modulation mode table 1.21: timer speci?cations in pulse-width modulation mode item speci?cation count source f1, f8, f32 count operation ?the timer counts down (operating as an 8-bit or a 16-bit pulse-width modulator) ?the timer reloads a new count at a rising edge of pwm pulse and continues counting ? the timer is not affected by a trigger that occurs when counting 16-bit pwm ?high level width n / f i n: set value ?cycle time (216-1) / f i ?xed 8-bit pwm ?high level width n (m+1) /f i n: values set to timer ai registers high-order address ?cycle time (28-1) (m+1) /f i m: values set to timer ai registers low-order address count start condition ?external trigger is input ?the timer over?ows ?the count start ?ag is set (= 1) count stop condition ?the count start ?ag is reset (= 0) interrupt request generation timing pwm pulse goes l taiin pin function programmable i/o port or trigger input taiout pin function pulse output read from timer when timer ai register is read, it indicates an indeterminate value write to timer ?when counting is stopped and a value is written to timer ai register, it is written to both reload register and the counter ?when counting in progress and a value is written to timer a register, it is written to only reload register to be transferred to the counter at next reload timer. note 1: valid only when the tai in pin is selected by the event/trigger select bit. (addresses 0382 16 and 0383 16 ). if timer overflow is selected, this bit can be "1", or "0". note 2: set the corresponding port direction register to 0. timer ai mode register symbol address when reset taimr(i=0 to 4) 0396 16 to 039a 16 00 16 bit name function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 operation mode select bit 1 1 : pwm mode b1 b0 tmod1 tmod0 mr0 external trigger select bit (note 1) 0 : falling edge of tai in pin's input signal (note 2) 1 : rising edge of tai in pin's input signal (note 2) mr2 mr1 mr3 must always be "1" in pwm mode) 0 0 : f 1 0 1 : f 8 1 0 : f 32 1 1 : reserved b7 b6 tck1 tck0 count source select bit 11 1 w r trigger select bit 0 : functions as a 16-bit pulse width modulator 1 : functions as an 8-bit pulse width modulator 16/8 pwm mode select bit 0 : count strat flig is valid 1 : selected by event /trigger select register
1-79 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timer a figure 1.68: example of how a 16-bit pulse-width modulator operates figure 1.69: example of how an 8-bit pulse-width modulator operates 1 / f i x (2 ?1) 16 count source ta iin pin input signal pwm pulse output from ta iout pin condition : reload register = 0003 16 , when external trigger (rising edge of ta iin pin input signal) is selected trigger is not generated by this signal ? ? ? ? timer ai interrupt request bit ? ? cleared to ??when interrupt request is accepted, or cleared by software f i : frequency of count source (f 1 , f 8 , f 32 ) note: n = 0000 16 to fffe 16 . 1 / f i x n count source (note1) ta iin pin input signal underflow signal of 8-bit prescaler (note2) pwm pulse output from ta iout pin ? ? ? ? ? ? ? ? timer ai interrupt request bit cleared to ??when interrupt request is accepted, or cleared by software f i : frequency of count source (f 1 , f 8 , f 32 ) note 1: the 8-bit prescaler counts the count source. note 2: the 8-bit pulse width modulator counts the 8-bit prescaler's underflow signal. note 3: m = 00 16 to fe 16 ; n = 00 16 to fe 16 . condition : reload register high-order 8 bits = 02 16 reload register low-order 8 bits = 02 16 external trigger (falling edge of ta iin pin input signal) is selected 1 / f i x (m + 1) x (2 ?1) 8 1 / f i x (m + 1) x n 1 / f i x (m + 1)
1-80 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timer b 2.22 timer b figure 1.70 shows the block diagram of timer b. figure 1.71 and figure 1.72 show the timer b-related registers. use the timer bi mode register ( i=0to2) bits 0 and 1 to choose the desired mode. timer b works in timer mode only (i.e., the timer counts an in internal count source). figure 1.70: block diagram of timer b figure 1.71: timer b-related registers clock source selection (address 0380 16 ) reload register (16) low-order 8 bits high-order 8 bits data bus low-order bits data bus high-order bits f 1 f 8 f 32 count start flag counter reset circuit counter (16) address 0391 16 0390 16 0393 16 0392 16 0395 16 0394 16 tbi timer b0 timer b1 timer b2 tbj timer b2 timer b0 timer b1 tbj overflow (j=i - 1. note, however, j = 2 when i = 0) note 1: timer b0. note 2: timer b1, timer b2. timer bi mode register symbol address when reset tbimr(i=0 to 2) 039b 16 to 039d 16 00xx0000 2 bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 operation mode select bit 0 0 : timer mode b1 b0 tmod1 tmod0 mr0 invalid in timer mode can be 0 or 1 mr2 mr1 mr3 0 0 : f 1 0 1 : f 8 1 0 : f 32 1 1 : reserved tck1 tck0 count source select bit 0 invalid in timer mode. this bit can neither be set nor reset. when read in timer mode, its content is indeterminate. 0 0 (fixed to 0 in timer mode ; i = 0) nothing is assiigned (i = 1, 2). this bit can neither be set nor reset. when read, its content is indeterminate. (note 1) (note 2) b7 b6
1-81 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timer b figure 1.72: timer b-related registers 2.22.1 timer mode in this mode, the timer counts an internally generated count source. (see table 1.22 ) figure 1.73 shows the timer bi mode register in timer mode. note: timer b2 does not generate an interrupt; it is used only as a prescaler. table 1.22: timer speci?cations in timer mode item speci?cation count source f1, f8, f32 count operation ?counts down ?when the timer under?ows, it reloads the reload register contents before continuing counting divide ratio 1/(n+1) n: set value count start condition count start ?ag is set (= 1) count stop condition count start ?ag is reset (= 0) interrupt request generation timing the timer under?ows (see note) symbol address when reset tabsr 0380 16 00 16 count start flag bit name bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 timer b2 count start flag timer b1 count start flag timer b0 count start flag timer a4 count start flag timer a3 count start flag timer a2 count start flag timer a1 count start flag timer a0 count start flag 0 : stops counting 1 : starts counting tb2s tb1s tb0s ta4s ta3s ta2s ta1s ta0s function symbol address when reset tb0 0391 16 , 0390 16 indeterminate tb1 0393 16 , 0392 16 indeterminate tb2 0395 16 , 0394 16 indeterminate tb3 0351 16 , 0350 16 indeterminate tb4 0353 16 , 0352 16 indeterminate tb5 0355 16 , 0354 16 indeterminate b7 b0 b7 b0 (b15) (b8) timer bi register (note) w r ? timer mode 0000 16 to ffff 16 counts the timer's period function values that can be set note: read and write data in 16-bit units.
1-82 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timer b figure 1.73: timer bi mode register in timer mode note 1: timer b0. note 2: timer b1, timer b2. timer bi mode register symbol address when reset tbimr(i=0 to 2) 039b 16 to 039d 16 00xx0000 2 bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 operation mode select bit 0 0 : timer mode b1 b0 tmod1 tmod0 mr0 invalid in timer mode can be 0 or 1 mr2 mr1 mr3 0 0 : f 1 0 1 : f 8 1 0 : f 32 1 1 : reserved tck1 tck0 count source select bit 0 invalid in timer mode. in an attempt to write to this bit, write 0. the value, if read in timer mode, turns out to be indeterminate. 0 0 (fixed to 0 in timer mode ; i = 0) nothing is assiigned (i = 1, 2). in an attempt to write to this bit, write 0. the value, if read, turns out to be indeterminate. (note 1) (note 2) b7 b6
1-83 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 2.23 uart0 through uart2 serial i/o is configured as three channels: uart0, uart1, and uart2. uart0, uart1, and uart2 each have an exclusive timer to generate a transfer clock, so they operate independently of each other. figure 1.74 shows the block diagram of uart0, uart1, and uart2. figure 1.74: block diagram of uarti (i=0 to 2) n0 : values set to uart0 bit rate generator (brg0) n1 : values set to uart1 bit rate generator (brg1) n2 : values set to uart2 bit rate generator (brg2) rxd 2 reception control circuit transmission control circuit 1 / (n 2 +1) 1/16 1/16 1/2 bit rate generator (address 0379 16 ) clock synchronous type (when internal clock is selected) uart reception clock synchronous type uart transmission clock synchronous type clock synchronous type (when internal clock is selected) clock synchronous type (when external clock is selected) receive clock transmit clock clk 2 cts 2 / rts 2 f 1 f 8 f 32 vcc rts 2 cts 2 txd 2 (uart2) rxd polarity reversing circuit txd polarity reversing circuit rxd 0 1 / (n 0 +1) 1/2 bit rate generator (address 03a1 16 ) clock synchronous type (when internal clock is selected) uart reception clock synchronous type uart transmission clock synchronous type clock synchronous type (when internal clock is selected) clock synchronous type (when external clock is selected) receive clock transmit clock clk 0 clock source selection cts 0 / rts 0 f 1 f 8 f 32 reception control circuit transmission control circuit internal external rts 0 cts 0 txd 0 transmit/ receive unit rxd 1 1 / (n 1 +1) 1/16 1/16 1/2 bit rate generator (address 03a9 16 ) clock synchronous type (when internal clock is selected) uart reception clock synchronous type uart transmission clock synchronous type clock synchronous type (when internal clock is selected) clock synchronous type (when external clock is selected) receive clock transmit clock clk 1 clock source selection f 1 f 8 f 32 reception control circuit transmission control circuit internal external rts 1 cts 1 txd 1 (uart1) (uart0) clk polarity reversing circuit clk polarity reversing circuit cts/rts disabled clock output pin select switch cts 1 / rts 1 clks 1 cts/rts disabled cts/rts selected cts/rts disabled v cc cts/rts disabled cts/rts disabled cts/rts disabled cts/rts selected clk polarity reversing circuit internal external clock source selection transmit/ receive unit transmit/ receive unit 1/16 1/16 v cc
1-84 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 figure 1.75 and figure 1.76 show the block diagram of the transmit/receive unit. figure 1.75: block diagram of uarti (i=0,1) transmit/receive circuit figure 1.76: block diagram of uart2 transmit/receive circuit sp sp par 2sp 1sp uart uart (7 bits) uart (8 bits) uart (7 bits) uart (9 bits) clock synchronous type clock synchronous type txdi uarti transmit register par enabled par disabled d 8 d 7 d 6 d 5 d 4 d 3 d 2 d 1 d 0 sp: stop bit par: parity bit uarti transmit buffer register msb/lsb conversion circuit uart (8 bits) uart (9 bits) clock synchronous type uarti receive buffer register uarti receive register 2sp 1sp par enabled par disabled uart uart (7 bits) uart (9 bits) clock synchronous type clock synchronous type uart (7 bits) uart (8 bits) rxdi clock synchronous type uart (8 bits) uart (9 bits) address 03a6 16 address 03a7 16 address 03ae 16 address 03af 16 address 03a2 16 address 03a3 16 address 03aa 16 address 03ab 16 data bus low-order bits msb/lsb conversion circuit d 7 d 6 d 5 d 4 d 3 d 2 d 1 d 0 d 8 0000000 sp sp par ? data bus high-order bits sp sp par 2sp 1sp uart uart (7 bits) uart (8 bits) uart(7 bits) uart (9 bits) clock synchronous type clock synchronous type data bus low-order bits txd2 uart2 transmit register par disabled par enabled d 8 d 7 d 6 d 5 d 4 d 3 d 2 d 1 d 0 uart2 transmit buffer register uart (8 bits) uart (9 bits) clock synchronous type uart2 receive buffer register uart2 receive register 2sp 1sp uart (7 bits) uart (8 bits) uart(7 bits) uart (9 bits) clock synchronous type clock synchronous type rxd2 uart (8 bits) uart (9 bits) address 037e 16 address 037f 16 address 037a 16 address 037b 16 data bus high-order bits d 7 d 6 d 5 d 4 d 3 d 2 d 1 d 0 d 8 0000000 sp sp par ? reverse no reverse error signal output circuit rxd data reverse circuit error signal output enable error signal output disable reverse no reverse logic reverse circuit + msb/lsb conversion circuit logic reverse circuit + msb/lsb conversion circuit par enabled par disabled uart clock synchronous type txd data reverse circuit sp: stop bit par: parity bit
1-85 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 uarti (i = 0 to 2) has two operation modes: a clock synchronous serial i/o mode and a clock asynchronous serial i/o mode (uart mode). the contents of the serial i/o mode select bits (bits 0 to 2 at addresses 03a0 16 , 03a8 16 and 0378 16 ) determine whether uarti is used as a clock synchronous serial i/o or as a uart. although a few functions are different, uart0 and uart1 have almost the same functions. uart0 through uart2 are almost equal in their functions with minor exceptions.table 1.23 shows the comparison of functions of uart0 through uart2, and figure 1.77, figure 1.78, figure 1.79, figure 1.80, and figure 1.81 show the registers related to uarti. note 1: only during clock synchronous serial i/o mode. note 2: only during clock synchronous serial i/o mode and 8-bit uart mode. note 3: only during uart mode. note 4: used for sim interface. table 1.23: comparison of functions of uart0 through uart2 function uart0 uart1 uart2 clk polarity selection possible (note 1) possible (note 1) possible (note 1) lsb ?rst / msb ?rst selection possible (note 1) possible (note 1) possible (note 2) continuous receive mode selection possible (note 1) possible (note 1) possible (note 1) transfer clock output from multiple pins selection impossible possible (note 1) impossible serial data logic switch impossible impossible possible (note 4) sleep mode selection possible (note 3) possible (note 3) impossible txd, rxd i/o polarity switch impossible impossible possible txd, rxd port output format cmos output cmos output cmos output parity error signal output impossible impossible possible (note 4) bus collision detection impossible impossible possible
1-86 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 figure 1.77: serial i/o-related registers (1) b7 uarti bit rate generator b0 symbol address when reset u0brg 03a1 16 indeterminate u1brg 03a9 16 indeterminate u2brg 0379 16 indeterminate function assuming that set value = n, brgi divides the count source by n + 1 00 16 to ff 16 values that can be set w r b7 b0 (b15) (b8) b7 b0 uarti transmit buffer register function transmit data nothing is assigned. these bits can neither be set nor reset. when read, their contents are indeterminate. symbol address when reset u0tb 03a3 16 , 03a2 16 indeterminate u1tb 03ab 16 , 03aa 16 indeterminate u2tb 037b 16 , 037a 16 indeterminate w r (b15) symbol address when reset u0rb 03a7 16 , 03a6 16 indeterminate u1rb 03af 16 , 03ae 16 indeterminate u2rb 037f 16 , 037e 16 indeterminate b7 b0 (b8) b7 b0 uarti receive buffer register function (during uart mode) function (during clock synchronous serial i/o mode) bit name bit symbol 0 : no framing error 1 : framing error found 0 : no parity error 1 : parity error found 0 : no error 1 : error found note 1: bits 15 through 12 are set to 0 when the serial i/o mode select bit (bits 2 to 0 at addresses 03a0 16 , 03a8 16 and 0378 16 ) are set to 000 2 or the receive enable bit is set to 0. (bit 15 is set to 0 when bits 14 to 12 all are set to 0.) bits 14 and 13 are also set to 0 when the lower byte of the uarti receive buffer register (addresses 03a6 16 , 03ae 16 and 037e 16 ) is read out. invalid invalid invalid oer fer per sum overrun error flag (note 1) framing error flag (note 1) parity error flag (note 1) error sum flag (note 1) 0 : no overrun error 1 : overrun error found 0 : no overrun error 1 : overrun error found nothing is assigned. these bits can neither be set nor reset. when read, the value of these bits is 0. receive data w r receive data
1-87 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 figure 1.78: serial i/o-related registers (2) uarti transmit/receive mode register symbol address when reset uimr(i=0,1) 03a0 16 , 03a8 16 00 16 b7 b6 b5 b4 b3 b2 b1 b0 bit name bit symbol w r must be fixed to 001 0 0 0 : serial i/o invalid 0 1 0 : inhibited 0 1 1 : inhibited 1 1 1 : inhibited b2 b1 b0 ckdir smd1 smd0 serial i/o mode select bit smd2 internal/external clock select bit stps pry prye slep parity enable bit 0 : internal clock 1 : external clock stop bit length select bit odd/even parity select bit sleep select bit 0 : one stop bit 1 : two stop bits 0 : parity disabled 1 : parity enabled 0 : sleep mode deselected 1 : sleep mode selected 1 0 0 : transfer data 7 bits long 1 0 1 : transfer data 8 bits long 1 1 0 : transfer data 9 bits long 0 0 0 : serial i/o invalid 0 1 0 : inhibited 0 1 1 : inhibited 1 1 1 : inhibited b2 b1 b0 0 : internal clock 1 : external clock invalid valid when bit 6 = ? 0 : odd parity 1 : even parity invalid invalid must always be ? function (during uart mode) function (during clock synchronous serial i/o mode) uart2 transmit/receive mode register symbol address when reset u2mr 0378 16 00 16 b7 b6 b5 b4 b3 b2 b1 b0 bit name bit symbol w r must be fixed to 001 0 0 0 : serial i/o invalid 0 1 1 : inhibited 1 1 1 : inhibited b2 b1 b0 ckdir smd1 smd0 serial i/o mode select bit smd2 internal/external clock select bit stps pry prye iopol parity enable bit 0 : internal clock 1 : external clock stop bit length select bit odd/even parity select bit txd, rxd i/o polarity reverse bit 0 : one stop bit 1 : two stop bits 0 : parity disabled 1 : parity enabled 0 : no reverse 1 : reverse usually set to ? 1 0 0 : transfer data 7 bits long 1 0 1 : transfer data 8 bits long 1 1 0 : transfer data 9 bits long 0 0 0 : serial i/o invalid 0 1 1 : inhibited 1 1 1 : inhibited b2 b1 b0 0 : internal clock 1 : external clock invalid valid when bit 6 = ? 0 : odd parity 1 : even parity invalid invalid 0 : no reverse 1 : reverse usually set to ? function (during uart mode) function (during clock synchronous serial i/o mode)
1-88 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 figure 1.79: serial i/o-related registers (3) uarti transmit/receive control register 0 symbol address when reset uic0(i=0,1) 03a4 16 , 03ac 16 08 16 b7 b6 b5 b4 b3 b2 b1 b0 function (during uart mode) w r function (during clock synchronous serial i/o mode) txept clk1 clk0 crs crd ckpol brg count source select bit transmit register empty flag 0 : transmit data is output at falling edge of transfer clock and receive data is input at rising edge 1 : transmit data is output at rising edge of transfer clock and receive data is input at falling edge clk polarity select bit cts/rts function select bit cts/rts disable bit 0 0 : f 1 is selected 0 1 : f 8 is selected 1 0 : f 32 is selected 1 1 : reserved b1 b0 0 : lsb first 1 : msb first 0 : data present in transmit register (during transmission) 1 : no data present in transmit register (transmission completed) 0 : cts/rts function enabled 1 : cts/rts function disabled (p6 0 and p6 4 function as programmable i/o port) uform transfer format select bit 0 0 : f 1 is selected 0 1 : f 8 is selected 1 0 : f 32 is selected 1 1 : reserved b1 b0 valid when bit 4 = 0 0 : cts function is selected (note 1) 1 : rts function is selected (note 2) valid when bit 4 = 0 0 : cts function is selected (note 1) 1 : rts function is selected (note 2) 0 : data present in transmit register (during transmission) 1 : no data present in transmit register (transmission completed) must always be 0 bit name bit symbol must always be 0 note 1: set the corresponding port direction register to 0. note 2: the settings of the corresponding port register and port direction register are invalid. 0 : cts/rts function enabled 1 : cts/rts function disabled (p6 0 and p6 4 function as programmable i/o port) uart2 transmit/receive control register 0 symbol address when reset u2c0 037c 16 08 16 b7 b6 b5 b4 b3 b2 b1 b0 function (during uart mode) w r function (during clock synchronous serial i/o mode) txept clk1 clk0 crs crd ckpol brg count source select bit transmit register empty flag 0 : transmit data is output at falling edge of transfer clock and receive data is input at rising edge 1 : transmit data is output at rising edge of transfer clock and receive data is input at falling edge clk polarity select bit cts/rts function select bit cts/rts disable bit 0 0 : f 1 is selected 0 1 : f 8 is selected 1 0 : f 32 is selected 1 1 : inhibited b1 b0 0 : lsb first 1 : msb first 0 : data present in transmit register (during transmission) 1 : no data present in transmit register (transmission completed) 0 : cts/rts function enabled 1 : cts/rts function disabled (p7 3 functions programmable i/o port) 0 : txdi pin is cmos output 1 : txdi pin is n-channel open-drain output uform transfer format select bit (note 3) 0 0 : f 1 is selected 0 1 : f 8 is selected 1 0 : f 32 is selected 1 1 : inhibited b1 b0 valid when bit 4 = 0 0 : cts function is selected (note 1) 1 : rts function is selected (note 2) valid when bit 4 = 0 0 : cts function is selected (note 1) 1 : rts function is selected (note 2) 0 : data present in transmit register (during transmission) 1 : no data present in transmit register (transmission completed) 0: txdi pin is cmos output 1: txdi pin is n-channel open-drain output must always be 0 bit name bit symbol note 1: set the corresponding port direction register to 0. note 2: the settings of the corresponding port register and port direction register are invalid. note 3: only clock synchronous serial i/o mode and 8-bit uart mode are valid. 0 : cts/rts function enabled 1 : cts/rts function disabled (p7 3 functions programmable i/o port) nothing is assigned. this bit can neither be set nor reset. when read, the value of this bit is 0. 0 : lsb first 1 : msb first nothing is assigned. this bit can neither be set nor reset. when read, the value of this bit is 0.
1-89 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 figure 1.80: serial i/o-related registers (4) uarti transmit/receive control register 1 symbol address when reset uic1(i=0,1) 03a5 16 , 03ad 16 02 16 b7 b6 b5 b4 b3 b2 b1 b0 bit name bit symbol w r function (during uart mode) function (during clock synchronous serial i/o mode) te ti re ri transmit enable bit receive enable bit receive complete flag transmit buffer empty flag 0 : transmission disabled 1 : transmission enabled 0 : data present in transmit buffer register 1 : no data present in transmit buffer register 0 : reception disabled 1 : reception enabled 0 : transmission disabled 1 : transmission enabled 0 : data present in transmit buffer register 1 : no data present in transmit buffer register 0 : reception disabled 1 : reception enabled 0 : no data present in receive buffer register 1 : data present in receive buffer register 0 : no data present in receive buffer register 1 : data present in receive buffer register nothing is assigned. these bits can neither be set nor reset. when read, the value of these bits is ?? uart2 transmit/receive control register 1 symbol address when reset u2c1 037d 16 02 16 b7 b6 b5 b4 b3 b2 b1 b0 bit name bit symbol w r function (during uart mode) function (during clock synchronous serial i/o mode) te ti re ri transmit enable bit receive enable bit receive complete flag transmit buffer empty flag 0 : transmission disabled 1 : transmission enabled 0 : data present in transmit buffer register 1 : no data present in transmit buffer register 0 : reception disabled 1 : reception enabled 0 : transmission disabled 1 : transmission enabled 0 : data present in transmit buffer register 1 : no data present in transmit buffer register 0 : reception disabled 1 : reception enabled 0 : no data present in receive buffer register 1 : data present in receive buffer register 0 : no data present in receive buffer register 1 : data present in receive buffer register u2irs uart2 transmit interrupt cause select bit 0 : transmit buffer empty (ti = 1) 1 : transmit is completed (txept = 1) 0 : transmit buffer empty (ti = 1) 1 : transmit is completed (txept = 1) u2rrm uart2 continuous receive mode enable bit 0 : continuous receive mode disabled 1 : continuous receive mode enabled invalid data logic select bit 0 : no reverse 1 : reverse 0 : no reverse 1 : reverse u2lch u2ere error signal output enable bit must be fixed to ? 0 : output disabled 1 : output enabled a a a a a a a a a a a a a a a a a a a a a a
1-90 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 figure 1.81: serial i/o-related registers (5) note: when using multiple pins to output the transfer clock, the following requirements must be met: ? uart1 internal/external clock select bit (bit 3 at address 03a8 16 ) = 0. uart transmit/receive control register 2 symbol address when reset ucon 03b0 16 x0000000 2 b7 b6 b5 b4 b3 b2 b1 b0 bit name bit symbol w r function (during uart mode) function (during clock synchronous serial i/o mode) clkmd0 clkmd1 uart0 transmit interrupt cause select bit uart0 continuous receive mode enable bit 0 : continuous receive mode disabled 1 : continuous receive mode enable uart1 continuous receive mode enable bit clk/clks select bit 0 uart1 transmit interrupt cause select bit 0 : transmit buffer empty (tl = 1) 1 : transmission completed (txept = 1) 0 : transmit buffer empty (tl = 1) 1 : transmission completed (txept = 1) 0 : normal mode (clk output is clk1 only) 1 : transfer clock output from multiple pins function selected 0 : continuous receive mode disabled 1 : continuous receive mode enabled nothing is assigned. this bit can neither be set nor reset. when read, its content is indeterminate. 0 : transmit buffer empty (tl = 1) 1 : transmission completed (txept = 1) 0 : transmit buffer empty (tl = 1) 1 : transmission completed (txept = 1) must always be 0 u0irs u1irs u0rrm u1rrm invalid invalid invalid clk/clks select bit 1 (note) valid when bit 5 = 1 0 : clock output to clk1 1 : clock output to clks1 must always be 0 reserved must always be 0
1-91 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 2.23.1 clock synchronous serial i/o mode the clock synchronous serial i/o mode uses a transfer clock to transmit and receive data. table 1.24 and table 1.25 list the specifications of the clock synchronous serial i/o mode. figure 1.82 shows the uarti transmit/receive mode register. note 1: n denotes the value 00 16 to ff 16 that is set to the uart bit rate generator. note 2: maximum 5 mbps. note 3: if an overrun error occurs, the uarti receive buffer will have the next data written in. note also that the uarti receive interrupt request bit is not set to 1. table 1.24: speci?cations of clock synchronous serial i/o mode (1) item speci?cation transfer data format ? transfer data length: 8 bits transfer clock ? when internal clock is selected (bit 3 at addresses 03a0 16 , 03a8 16 , 0378 16 = 0): ?=2(n+1) (note 1) ? = f1, f8, f32 ? when external clock is selected (bit 3 at addresses 03a0 16 , 03a8 16 , 0378 16 = 1): input from clki pin (note 2) transmission/reception control ? cts function/rts function/cts, rts function chosen to be invalid transmission start condition ? to start transmission, the following requirements must be met: _ transmit enable bit (bit 0 at addresses 03a5 16 , 03ad 16 , 037d 16 ) = 1 _ transmit buffer empty ?ag (bit 1 at addresses 03a5 16 , 03ad 16 , 037d 16 ) = 0 _ when cts function selected, cts input level = l ? furthermore, if external clock is selected, the following requirements must also be met: _ clki polarity select bit (bit 6 at addresses 03a4 16 , 03ac 16 , 037c 16 ) = 0: clki input level = h _ clki polarity select bit (bit 6 at addresses 03a4 16 , 03ac 16 , 037c 16 ) = 1: clki input level = l reception start condition ? to start reception, the following requirements must be met: _ receive enable bit (bit 2 at addresses 03a5 16 , 03ad 16 , 037d 16 ) = 1 _ transmit enable bit (bit 0 at addresses 03a5 16 , 03ad 16 , 037d 16) = 1 _ transmit buffer empty ?ag (bit 1 at addresses 03a5 16 , 03ad 16 , 037d 16 ) = 0 ? furthermore, if external clock is selected, the following requirements must also be met: _ clki polarity select bit (bit 6 at addresses 03a4 16 , 03ac 16 , 037c 16 ) = 0: clki input level = h _ clki polarity select bit (bit 6 at addresses 03a4 16 , 03ac 16 , 037c 16 ) = 1: clki input level = l ? when transmitting _ transmit interrupt cause select bit (bits 0, 1 at address 03b0 16 , bit 4 at address 037d 16 ) = 0: interrupts requested when data transfer from uarti _ transmit interrupt cause select bit (bits 0, 1 at address 03b0 16 , bit 4 at address 037d 16 ) = 1: interrupts requested when data transmission from error detection ? overrun error (note 3) this error occurs when the next data is ready before contents of uarti receive buffer is read.
1-92 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 figure 1.82: uarti transmit/receive mode register in clock synchronous serial i/o mode table 1.25: speci?cations of clock synchronous serial i/o mode (2) item speci?cation select function ? clk polarity selection whether transmit data is output/input at the rising edge or falling edge of the transfer clock can be selected ? lsb ?rst/msb ?rst selection whether transmission/reception begins with bit 0 or bit 7 can be selected ? continuous receive mode selection reception is enabled simultaneously by a read from the receive buffer register ? transfer clock output from multiple pins selection (uart1) uart1 transfer clock can be chosen by software to be output from one of the two pins set ? switching serial data logic (uart2) whether to reverse data in writing to the transmission buffer register or reading the reception buffer register can be selected. ? switching serial data logic (uart2) this function is reversing txd port output and rxd port input. all i/o data level is reversed. symbol address when reset uimr(i=0,1) 03a0 16 , 03a8 16 00 16 ckdir uarti transmit/receive mode registers internal/external clock select bit stps pry prye slep 0 : internal clock 1 : external clock bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 0 (must always be ??in clock synchronous serial i/o mode) 01 0 smd0 smd1 smd2 serial i/o mode select bit 0 0 1 : clock synchronous serial i/o mode b2 b1 b0 0 invalid in clock synchronous serial i/o mode symbol address when reset u2mr 0378 16 00 16 ckdir uart2 transmit/receive mode register internal/external clock select bit stps pry prye iopol 0 : internal clock 1 : external clock bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 01 0 smd0 smd1 smd2 serial i/o mode select bit 0 0 1 : clock synchronous serial i/o mode b2 b1 b0 0 invalid in clock synchronous serial i/o mode txd, rxd i/o polarity reverse bit (note) 0 : no reverse 1 : reverse note: usually set to ?? a aa a aa a a aa aa a a aa aa a aa a aa a aa a aa a aa a aa a a aa aa a aa a aa a a aa aa a aa a aa
1-93 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 table 1.26 lists the functions of the input/output pins during clock synchronous serial i/o mode. this table shows the pin functions when the transfer clock output from multiple pins function is not selected. note that for a period from when the uarti operation mode is selected to when transfer starts, the txd pin outputs a h. the typical clock synchronous timing diagrams are shown in figure 1.83. table 1.26: input/output pin functions in clock synchronous serial i/o mode pin name function method of selection txdi (p63, p67, p70) serial data output (outputs dummy data when performing reception only) rxdi (p62, p66, p71) serial data input port p62, p66, and p71 direction register (bits 2 and 6 at address 03ee 16 bit 1 at address 03ef 16 )= 0 (can be used as an input port when performing transmission only.) clki (p61, p65, p72) transfer clock output internal/external clock select bit (bit 3 at address 03a0 16 , 03a8 16 , 0378 16 ) = 0 transfer clock input internal/external clock select bit (bit 3 at address 03a0 16 , 03a8 16 , 0378 16 ) = 1 port p61, p65, and p72 direction register (bits 1 and 5 at address 03ee 16 , bit 2 at address 03ef 16 ) = 0 ctsi/ rtsi (p60,p64,p73) cts input cts/ rts disable bit (bit 4 at address 03a4 16 , 03ac 16 , 037c 16 ) = 0 cts/ rts function select bit (bit 2 at address 03a4 16 , 03ac 16 , 037c 16 ) = 0 port p60, p64 and p73 direction register (bits 0 and 4 at address 03ee 16 , bit 3 at address 03ef 16 ) = 0 rts output cts/ rts disable bit (bit 4 at address 03a4 16 , 03ac 16 , 037c 16 ) = 0 cts/ rts function select bit (bit 2 at address 03a4 16 , 03ac 16 , 037c 16 ) = 1 programmable i/o port cts/ rts disable bit (bit 4 at address 03a4 16 , 03ac 16 , 037c 16 ) = 1
1-94 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 figure 1.83: typical transmit/receive timings in clock synchronous serial i/o mode polarity select function d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 tc t clk stopped pulsing because transfer enable bit = ? data is set in uarti transmit buffer register tc = tclk = 2(n + 1) / fi fi: frequency of brgi count source (f 1 , f 8 , f 32 ) n: value set to brgi transfer clock transmit enable bit (te) transmit buffer empty flag (tl) clki txdi transmit register empty flag (txept) ? ? ? ? ? ? ? ? ctsi the above timing applies to the following settings: ?internal clock is selected. ?cts function is selected. ?clk polarity select bit = ?? ?transmit interrupt cause select bit = ?? transmit interrupt request bit (ir) ? ? stopped pulsing because cts = ? 1 / f ext dummy data is set in uarti transmit buffer register transmit enable bit (te) transmit buffer empty flag (tl) clki rxdi receive complete flag (rl) rtsi ? ? ? ? ? ? ? ? receive enable bit (re) ? ? receive data is taken in transferred from uarti transmit buffer register to uarti transmit register read out from uarti receive buffer register the above timing applies to the following settings: ?external clock is selected. ?rts function is selected. ?clk polarity select bit = ?? f ext : frequency of external clock transferred from uarti receive register to uarti receive buffer register receive interrupt request bit (ir) ? ? d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 d 0 d 1 d 2 d 3 d 4 d 5 shown in ( ) are bit symbols. transferred from uarti transmit buffer register to uarti transmit register meet the following conditions are met when the clk input before data reception = ? ?transmit enable bit ? ?receive enable bit ? ?dummy data write to uarti transmit buffer register shown in ( ) are bit symbols. cleared to ??when interrupt request is accepted, or cleared by software cleared to ??when interrupt request is accepted, or cleared by software example of receive timing (when external clock is selected)
1-95 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 2.23.1.1 polarity select function as shown in figure 1.84, the clk polarity select bit (bit 6 at addresses 03a4 16 , 03ac 16 , 037c 16 ) allows se- lection of the polarity of the transfer clock. figure 1.84: polarity of transfer clock 2.23.1.2 lsb first/msb first select function as shown in figure 1.85, when the transfer format select bit (bit 7 at addresses 03a4 16 , 03ac 16 , 037c 16 )= 0, the transfer format is lsb first; when the bit = 1, the transfer format is msb first. figure 1.85: transfer format ?when clk polarity select bit = ? note 2: the clk pin level when not transferring data is ?? d 1 d 2 d 3 d 4 d 5 d 6 d 7 d 1 d 2 d 3 d 4 d 5 d 6 d 7 d 0 d 0 t x d i r x d i clk i ?when clk polarity select bit = ? note 1: the clk pin level when not transferring data is ?? d 1 d 2 d 3 d 4 d 5 d 6 d 7 d0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 d 0 t x d i r x d i clk i lsb first ?when transfer format select bit = ? d0 d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 d 1 d 2 d 3 d 4 d 5 d 6 d 7 t x d i r x d i clk i ?when transfer format select bit = ? d 6 d 5 d 4 d 3 d 2 d 1 d 0 d 7 d 7 d 6 d 5 d 4 d 3 d 2 d 1 d 0 t x d i r x d i clk i msb first note: this applies when the clk polarity select bit = ??
1-96 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 2.23.1.3 transfer clock output from multiple pins function (uart1) this function allows the setting two transfer clock output pins and choosing one of the two to output a clock by using the clk and clks select bit (bits 4 and 5 at address 03b0 16 ). see figure 1.86. the multiple pins function is valid only when the internal clock is selected for uart1. note that when this function is selected, uart1 cts/rts function cannot be used. figure 1.86: the transfer clock output from the multiple pins function usage 2.23.1.4 continuous receive mode if the continuous receive mode enable bit (bits 2 and 3 at address 03b0 16 , bit 5 at address 037d 16 ) is set to 1, the unit is placed in continuous receive mode. in this mode, when the receive buffer register is read out, the unit simultaneously goes to a receive enable state without having to set dummy data to the transmit buffer register back again. 2.23.1.5 serial data logic switch function (uart2) when the data logic select bit (bit6 at address 037d 16 ) = 1, and writing to transmit buffer register or reading from receive buffer register, data is reversed. figure 1.87 shows the example of serial data logic switch timing. figure 1.87: serial data logic switch timing microcomputer t x d 1 (p6 7 ) clks 1 (p6 4 ) clk 1 (p6 5 ) in clk in clk note: this applies when the internal clock is selected and transmission is performed only in clock synchronous serial i/o mode. d0 d1 d2 d3 d4 d5 d6 d7 d0 d1 d2 d3 d4 d5 d6 d7 transfer clock txd 2 (no reverse) txd 2 (reverse) ? ? ? ? ? ? ?hen lsb first
1-97 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 2.23.2 clock asynchronous serial i/o (uart) mode the uart mode allows transmitting and receiving data after setting the desired transfer rate and transfer data format. table 1.27 and table 1.28 list the specifications of the uart mode. figure 1.88 shows the uarti transmit/receive mode register. note 1: n denotes the value 00 16 to ff 16 that is set to the uarti bit rate generator. note 2: fext is input from the clki pin. note 3: if an overrun error occurs, the uarti receive buffer will have the next data written in. note also that the uarti receive interrupt request bit is not set to 1 table 1.27: speci?cations of uart mode (1) item speci?cation transfer data format ? character bit (transfer data): 7 bits, 8 bits, or 9 bits as selected ? start bit: 1 bit ? parity bit: odd, even, or nothing as selected ? stop bit: 1 bit or 2 bits as selected transfer clock ? when internal clock is selected (bit 3 at addresses 03a0 16 , 03a8 16 , 0378 16 = 0): ?/16(n+1) (note 1) ? = f1, f8, f32 ? when external clock is selected (bit 3 at addresses 03a0 16 , 03a816, 0378 16 =1): fext/16(n+1)(note 1) (note 2) transmission/reception control ? cts function/rts function/cts, rts function chosen to be invalid transmission start condition ? to start transmission, the following requirements must be met: - transmit enable bit (bit 0 at addresses 03a5 16 , 03ad 16 , 037d 16 ) = 1 - transmit buffer empty ?ag (bit 1 at addresses 03a5 16 , 03ad 16 , 037d 16 ) = 0 - when cts function selected, cts input level = l reception start condition ? to start reception, the following requirements must be met: - receive enable bit (bit 2 at addresses 03a5 16 , 03ad 16 , 037d 16 ) = 1 - start bit detection interrupt request generation timing ? when transmitting - transmit interrupt cause select bits (bits 0,1 at address 03b0 16 , bit4 at address 037d 16 ) = 0: interrupts requested when data transfer from uarti transfer buffer register to uarti transmit register is completed - transmit interrupt cause select bits (bits 0, 1 at address 03b0 16 , bit4 at address 037d 16 ) = 1: interrupts requested when data transmission from uarti transfer register is completed ? when receiving - interrupts requested when data transfer from uarti receive register to uarti receive buffer register is completed error detection ? overrun error (note 3) this error occurs when the next data is ready before contents of uarti receive buffer register are read out ? framing error this error occurs when the number of stop bits set is not detected ? parity error this error occurs when if parity is enabled, the number of 1s in parity and character bits does not match the number of 1s set ? error sum ?ag this ?ag is set (= 1) when any of the overrun, framing, and parity errors is encountered
1-98 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 figure 1.88: uarti transmit/receive mode register in uart mode table 1.28: speci?cations of uart mode (2) item speci?cation select function ? sleep mode selection (uart0, uart1) this mode is used to transfer data to and from one of multiple slave micro-computers ?serial data logic switch (uart2) this function is reversing logic value of transferring data. start bit, parity bit and stop bit are not reversed. ?txd, rxd i/o polarity switch this function is reversing txd port output and rxd port input. all i/o data level is reversed. symbol address when reset uimr(i=0,1) 03a0 16 , 03a8 16 00 16 ckdir uarti transmit / receive mode registers internal / external clock select bit stps pry prye slep 0 : internal clock 1 : external clock bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 smd0 smd1 smd2 serial i/o mode select bit b2 b1 b0 0 : one stop bit 1 : two stop bits 0 : parity disabled 1 : parity enabled 0 : sleep mode deselected 1 : sleep mode selected 1 0 0 : transfer data 7 bits long 1 0 1 : transfer data 8 bits long 1 1 0 : transfer data 9 bits long valid when bit 6 = ? 0 : odd parity 1 : even parity stop bit length select bit odd / even parity select bit parity enable bit sleep select bit symbol address when reset u2mr 0378 16 00 16 ckdir uart2 transmit / receive mode register internal / external clock select bit stps pry prye iopol 0 : internal clock 1 : external clock bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 smd0 smd1 smd2 serial i/o mode select bit b2 b1 b0 0 : one stop bit 1 : two stop bits 0 : parity disabled 1 : parity enabled 0 : no reverse 1 : reverse 1 0 0 : transfer data 7 bits long 1 0 1 : transfer data 8 bits long 1 1 0 : transfer data 9 bits long valid when bit 6 = ? 0 : odd parity 1 : even parity stop bit length select bit odd / even parity select bit parity enable bit txd, rxd i/o polarity reverse bit (note) a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a note: usually set to 0.
1-99 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 table 1.29 lists the functions of the input/output pins during uart mode. note that for a period from when the uarti operation mode is selected to when transfer starts, the txdi pin outputs a h. figure 1.89 and figure 1.90 show the typical uart mode transmit and receive timing diagrams. table 1.29: input/output pin functions in uart mode pin name function method of selection txdi (p63, p67, p70) serial data output rxdi (p62, p66, p71) serial data input port p62, p66, and p71 direction register (bits 2 and 6 at address 03ee 16 bit 1 at address 03ef 16 )= 0 (can be used as an input port when performing transmission only.) clki (p61, p65, p72) programmable i/o port internal/external clock select bit (bit 3 at address 03a0 16 , 03a8 16 , 0378 16 ) = 0 transfer clock input internal/external clock select bit (bit 3 at address 03a0 16 , 03a8 16 , 0378 16 ) = 1 port p61, p65, and p72 direction register (bits 1 and 5 at address 03ee 16 , bit 2 at address 03ef 16 ) = 0 ctsi/ rtsi (p60,p64,p73) cts input cts/ rts disable bit (bit 4 at address 03a4 16 , 03ac 16 , 037c 16 ) = 0 cts/ rts function select bit (bit 2 at address 03a4 16 , 03ac 16 , 037c 16 ) = 0 port p60, p64 and p73 direction register (bits 0 and 4 at address 03ee 16 , bit 3 at address 03ef 16 ) = 0 rts output cts/ rts disable bit (bit 4 at address 03a4 16 , 03ac 16 , 037c 16 ) = 0 cts/ rts function select bit (bit 2 at address 03a4 16 , 03ac 16 , 037c 16 ) = 1 programmable i/o port cts/ rts disable bit (bit 4 at address 03a4 16 , 03ac 16 , 037c 16 ) = 1
1-100 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 figure 1.89: typical transmit timings in uart mode transmit enable bit(te) transmit buffer empty flag(ti) transmit register empty flag (txept) start bit parity bit txdi ctsi the above timing applies to the following settings : ?parity is enabled. ?one stop bit. ?cts function is selected. ?transmit interrupt cause select bit = ?? ? ? ? ? ? ? ? tc = 16 (n + 1) / fi or 16 (n + 1) / f ext fi : frequency of brgi count source (f 1 , f 8 , f 32 ) f ext : frequency of brgi count source (external clock) n : value set to brgi transmit interrupt request bit (ir) ? ? cleared to ??when interrupt request is accepted, or cleared by software transmit enable bit(te) transmit buffer empty flag(ti) txdi transmit register empty flag (txept) ? ? ? ? ? ? the above timing applies to the following settings : ?parity is disabled. ?two stop bits. ?cts function is disabled. ?transmit interrupt cause select bit = ?? transfer clock tc tc = 16 (n + 1) / fi or 16 (n + 1) / f ext fi : frequency of brgi count source (f 1 , f 8 , f 32 ) f ext : frequency of brgi count source (external clock) n : value set to brgi transmit interrupt request bit (ir) ? ? shown in ( ) are bit symbols. shown in ( ) are bit symbols. tc transfer clock d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 st p d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 sp st p sp d 0 d 1 st stopped pulsing because transmit enable bit = ? stop bit transferred from uarti transmit buffer register to uarti transmit register start bit the transfer clock stops momentarily as cts is ??when the stop bit is checked. the transfer clock starts as the transfer starts immediately cts changes to ?? data is set in uarti transmit buffer register d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 st sp d 8 d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 st d 8 d 0 d 1 st sp sp transferred from uarti transmit buffer register to uarti transmit register stop bit stop bit data is set in uarti transmit buffer register. ? sp cleared to ??when interrupt request is accepted, or cleared by software ? example of transmit timing when transfer data is 8 bits long (parity enabled, one stop bit) ? example of receive timing when transfer data is 8 bits long (parity enabled, one stop bit)
1-101 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 figure 1.90: typical receive timing in uart mode 2.23.2.1 sleep mode (uart0, uart1) this mode is used to transfer data between specific microcomputers among multiple microcomputers con- nected using uarti. the sleep mode is selected when the sleep select bit (bit 7 at addresses 03a0 16 , 03a8 16 ) is set to 1 during reception. in this mode, the unit performs receive operation when the msb of the received data = 1 and does not perform receive operation when the msb = 0. 2.23.2.2 function for switching serial data logic (uart2) when the data logic select bit (bit 6 of address 037d 16 ) is assigned 1, data is inverted in writing to the trans- mission buffer register or reading the reception buffer register. figure 1.91 shows the example of timing for switching serial data logic. figure 1.91: timing for switching serial data logic d 0 start bit sampled ? receive data taken in brgi count source receive enable bit rxdi transfer clock receive complete flag rtsi stop bit ? ? ? ? ? ? the above timing applies to the following settings : ?arity is disabled. ?ne stop bit. ?ts function is selected. receive interrupt request bit ? ? transferred from uarti receive register to uarti receive buffer register reception triggered when transfer clock is generated by falling edge of start bit d 7 d 1 cleared to ??when interrupt request is accepted, or cleared by software example of receive timing when transfer data is 8 bits long (parity disabled, one stop bit) st : start bit p : even parity sp : stop bit d0 d1 d2 d3 d4 d5 d6 d7 p sp st sp st d3 d4 d5 d6 d7 p d0 d1 d2 transfer clock txd 2 (no reverse) txd 2 (reverse) ? ? ? ? ? ? ?when lsb first, parity enabled, one stop bit
1-102 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 2.23.2.3 txd, rxd i/o polarity reverse function (uart2) this function is to reverse txd pin output and rxd pin input. the level of any data to be input or output (in- cluding the start bit, stop bit(s), and parity bit) is reversed. set this function to 0 (not to reverse) for usual use. 2.23.2.4 bus collision detection function (uart2) this function is to sample the output level of the txd pin and the input level of the rxd pin at the rising edge of the transfer clock; if their values are different, then an interrupt request occurs. figure 1.92 shows the ex- ample of detection timing of a buss collision (in uart mode). figure 1.92: detection timing of a bus collision (in uart mode) st : start bit sp : stop bit st st sp sp transfer clock txd 2 rxd 2 bus collision detection interrupt request signal ? ? ? ? ? ? ? ? bus collision detection interrupt request bit ? ?
1-103 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 2.23.3 clock-asynchronous serial i/o mode (compliant with the sim interface) the sim interface is used for connecting the microcomputer with a memory card i/c or the like; adding some extra settings in uart2 clock-asynchronous serial i/o mode allows the user to effect this func- tion. table 1.30 shows the specifications of clock-asynchronous serial i/o mode (compliant with the sim interface). figure 1.93 shows the typical transmit/receive timing in uart mode. note 1: n denotes the value 00 16 to ff 16 that is set to the uarti bit rate generator. note 2: fext is input from the clk2 pin. note 3: if an overrun error occurs, the uart2 receive buffer will have the next data written in. note also that the uarti receive interrupt request bit is not set to 1. table 1.30: specifications of clock-asynchronous serial i/o mode (compliant with the sim interface) item speci?cation transfer data format ? transfer data 8-bit uart mode (bit 2 through bit 0 of address 0378 16 = 1012) ? one stop bit (bit 4 of address 0378 16 = 0) ? with the direct format chosen set parity to even (bit 5 and bit 6 of address 0378 16 = 1 and 1 respectively) set data logic to direct (bit 6 of address 037d 16 = 0). set transfer format to lsb (bit 7 of address 037c 16 = 0). ? with the inverse format chosen set parity to odd (bit 5 and bit 6 of address 0378 16 = 0 and 1 respectively) set data logic to inverse (bit 6 of address 037d 16 = 1) set transfer format to msb (bit 7 of address 037c 16 = 1) transfer clock ? with the internal clock chosen (bit 3 of address 0378 16 = 0): ? / 16 (n + 1) (note 1): ?=f1, f8, f32 ? with an external clock chosen (bit 3 of address 0378 16 = 1): fext / 16 (n+1) (note 1) (note 2) transmission / reception control ? disable the cts and rts function (bit 4 of address 037c 16 = 1) other settings ? the sleep mode select function is not available for uart2 ? set transmission interrupt factor to transmission completed (bit 4 of address 037d 16 = 1) transmission start condition ? to start transmission, the following requirements must be met: - transmit enable bit (bit 0 of address 037d 16 ) = 1 - transmit buffer empty ?ag (bit 1 of address 037d 16 ) = 0 reception start condition ? to start reception, the following requirements must be met: - reception enable bit (bit 2 of address 037d 16 ) = 1 - detection of a start bit ? when transmitting when data transmission from the uart2 transfer register is completed (bit 4 of address 037d 16 = 1) ? when receiving when data transfer from the uart2 receive register to the uart2 receive buffer register is completed error detection ? overrun error (see the speci?cations of clock-asynchronous serial i/o) (note 3) ? framing error (see the speci?cations of clock-asynchronous serial i/o) ? parity error (see the speci?cations of clock-asynchronous serial i/o) - on the reception side, an l level is output from the txd2 pin by use of the parity error signal output function (bit 7 of address 037d 16 = 1) when a parity error is detected - on the transmission side, a parity error is detected by the level of input to the rxd2 pin when a transmission interrupt occurs ? the error sum ?ag (see the speci?cations of clock-asynchronous serial i/o)
1-104 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 figure 1.93: typical transmit/receive timing in uart mode (compliant with the sim interface) transmit enable bit(te) transmit buffer empty flag(ti) transmit register empty flag (txept) d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 st p start bit parity bit the above timing applies to the following settings : ?parity is enabled. ?one stop bit. ?transmit interrupt cause select bit = ?? ? ? ? ? ? ? tc = 16 (n + 1) / fi or 16 (n + 1) / f ext fi : frequency of brgi count source (f 1 , f 8 , f 32 ) f ext : frequency of brgi count source (external clock) n : value set to brgi transmit interrupt request bit (ir) ? ? d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 st p shown in ( ) are bit symbols. tc transfer clock sp stop bit data is set in uarti transmit buffer register sp a ??level returns from txd 2 due to the occurrence of a parity error. the level is detected by the interrupt routine. the level is detected by the interrupt routine. receive enable bit (re) receive complete flag (ri) d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 st p start bit parity bit txd 2 the above timing applies to the following settings : ?parity is enabled. ?one stop bit. ?transmit interrupt cause select bit = ?? ? ? ? ? tc = 16 (n + 1) / fi or 16 (n + 1) / f ext fi : frequency of brgi count source (f 1 , f 8 , f 32 ) f ext : frequency of brgi count source (external clock) n : value set to brgi receive interrupt request bit (ir) ? ? d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 st p sp shown in ( ) are bit symbols. tc transfer clock sp stop bit a ??level returns from txd 2 due to the occurrence of a parity error. rxd 2 read to receive buffer read to receive buffer d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 st p signal conductor level (note 1) d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 st p sp sp d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 st p d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 st p sp sp txd 2 rxd 2 signal conductor level (note 1) note: equal in waveform because txd 2 and rxd 2 are connected. transferred from uarti transmit buffer register to uarti transmit register cleared to ??when interrupt request is accepted, or cleared by software cleared to ??when interrupt request is accepted, or cleared by software
1-105 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change uart0 through uart2 2.23.3.1 function for outputting a parity error signal with the error signal output enable bit (bit 7 of address 037d 16 ) assigned 1, you can output an l level from the txd2 pin when a parity error is detected. in step with this function, the generation timing of a transmission completion interrupt changes to the detection timing of a parity error signal. figure 1.94 shows the output tim- ing of the parity error signal. figure 1.94: output timing of the parity error signal 2.23.3.2 direct format/inverse format connecting the sim card allows you to switch between direct format and inverse format. if you choose the direct format, d0 data is output from txd2. if you choose the inverse format, d7 data is inverted and output from txd2. figure 1.95 shows the sim interface format. figure 1.95: sim interface format figure 1.96 shows the example of connecting the sim interface with txd2 and rxd2. figure 1.96: connecting the sim interface st : start bit p : even parity sp : stop bit d0 d1 d2 d3 d4 d5 d6 d7 p sp st hi-z transfer clock rxd 2 txd 2 receive complete flag ? ? ? ? ? ? ? ?lsb first ? p : even parity d0 d1 d2 d3 d4 d5 d6 d7 p transfer clcck txd 2 (direct) txd 2 (inverse) d7 d6 d5 d4 d3 d2 d1 d0 p microcomputer sim card txd 2 rxd 2
1-106 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change a-d converter 2.24 a-d converter the a-d converter consists of one 10-bit successive approximation a-d converter circuit with a capacitive coupling amplifier. pins p100 to p107 function as the analog signal input pins. the direction registers of these pins for a-d conversion must therefore be set to input. the vref connect bit (bit 5 at address 03d7 16 ) can be used to isolate the resistance ladder of the a-d converter from the reference voltage input pin (vref) when the a-d converter is not used. doing so stops any current flowing into the resistance ladder from vref, reducing the power dissipation. when using the a-d converter, start a-d conversion only after setting bit 5 of 03d7 16 to connect vref. the result of a-d conversion is stored in the a-d registers of the selected pins. when set to 10-bit precision, the low 8 bits are stored in the even addresses and the high 2 bits in the odd addresses. when set to 8-bit precision, the low 8 bits are stored in the even addresses. table 1.31 shows the performance of the a-d converter. figure 1.97 shows the block diagram of the a- d converter, and figure 1.98 and figure 1.99 show the a-d converter-related registers. table 1.31: performance of a-d converter item performance method of a-d conversion successive approximation (capacitive coupling ampli?er) analog input voltage (note) 0v to avcc (vcc) operating clock fad vcc = 5v fad/divide-by-2 or fad/divide-by-4 or fad, fad=f(xin) resolution 8-bit or 10-bit (selectable) absolute precision vcc = 5v ? without sample and hold function 3lsb ? with sample and hold function (8-bit resolution) 2lsb ? with sample and hold function (10-bit resolution) 3lsb operating modes one-shot mode, repeat mode, single sweep mode, repeat sweep mode 0, and repeat sweep mode 1 analog input pins 8pins (an0 to an7) a-d conversion start condition ?software trigger a-d conversion starts when the a-d conversion start ?ag changes to 1 ?external trigger (can be retriggered) a-d conversion starts when the a-d conversion start ?ag is 1 and the ad trg /p87 input changes from h to l conversion speed per pin ?without sample and hold function 8-bit resolution: 49 f ad cycles, 10-bit resolution: 59 f ad cycles ? with sample and hold function 8-bit resolution: 28 f ad cycles, 10-bit resolution: 33 f ad cycles note does not depend on use of sample and hold function.
1-107 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change a-d converter figure 1.97: block diagram of a-d converter 1/2 f ad 1/2 f ad a-d conversion rate selection (03c1 16 , 03c0 16 ) (03c3 16 , 03c2 16 ) (03c5 16 , 03c4 16 ) (03c7 16 , 03c6 16 ) (03c9 16 , 03c8 16 ) (03cb 16 , 03ca 16 ) (03cd 16 , 03cc 16 ) (03cf 16 , 03ce 16 ) cks1=1 cks0=0 a-d register 0(16) a-d register 1(16) a-d register 2(16) a-d register 3(16) a-d register 4(16) a-d register 5(16) a-d register 6(16) a-d register 7(16) resistor ladder successive conversion register an 0 an 1 an 2 an 3 an 5 an 6 an 7 a-d control register 0 (address 03d6 16 ) a-d control register 1 (address 03d7 16 ) v ref v in data bus high-order data bus low-order v ref an 4 vcut=0 av ss vcut=1 cks0=1 cks1=0 ch2,ch1,ch0=000 ch2,ch1,ch0=001 ch2,ch1,ch0=010 ch2,ch1,ch0=011 ch2,ch1,ch0=100 ch2,ch1,ch0=101 ch2,ch1,ch0=110 ch2,ch1,ch0=111 decoder comparator addresses
1-108 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change a-d converter figure 1.98: a-d converter-related registers (1) a-d control register 0 (note 1) symbol address when reset adcon0 03d6 16 00000xxx 2 b7 b6 b5 b4 b3 b2 b1 b0 analog input pin select bit 0 0 0 : an 0 is selected 0 0 1 : an 1 is selected 0 1 0 : an 2 is selected 0 1 1 : an 3 is selected 1 0 0 : an 4 is selected 1 0 1 : an 5 is selected 1 1 0 : an 6 is selected 1 1 1 : an 7 is selected (note 2) ch0 bit symbol bit name function ch1 ch2 a-d operation mode select bit 0 0 0 : one-shot mode 0 1 : repeat mode 1 0 : single sweep mode 1 1 : repeat sweep mode 0 repeat sweep mode 1 (note 2) md0 md1 trigger select bit 0 : software trigger 1 : ad trg trigger trg adst a-d conversion start flag 0 : a-d conversion disabled 1 : a-d conversion started frequency select bit 0 0 : f ad /4 is selected 1 : f ad /2 is selected cks0 w r a-d control register 1 (note) symbol address when reset adcon1 03d7 16 00 16 bit name function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 a-d sweep pin select bit scan0 scan1 md2 bits 8/10-bit mode select bit 0 : 8-bit mode 1 : 10-bit mode vcut vref connect bit a-d operation mode select bit 1 0 : any mode other than repeat sweep mode 1 1 : repeat sweep mode 1 0 : vref not connected 1 : vref connected w r b2 b1 b0 b4 b3 when single sweep and repeat sweep mode 0 are selected 0 0 : an 0 , an 1 (2 pins) 0 1 : an 0 to an 3 (4 pins) 1 0 : an 0 to an 5 (6 pins) 1 1 : an 0 to an 7 (8 pins) b1 b0 when repeat sweep mode 1 is selected 0 0 : an 0 (1 pin) 0 1 : an 0 , an 1 (2 pins) 1 0 : an 0 to an 2 (3 pins) 1 1 : an 0 to an 3 (4 pins) b1 b0 note 1: if the a-d control register is rewritten during a-d conversion, the conversion result is indeterminate. note 2: when changing a-d operation mode, set analog input pin again. frequency select bit 1 0 : f ad /2 or f ad /4 is selected 1 : f ad is selected cks1 note: if the a-d control register is rewritten during a-d conversion, the conversion result is indeterminate. reserved bit always set to "0" 0 0
1-109 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change a-d converter figure 1.99: a-d converter-related registers (2) a-d control register 2 (note) symbol address when reset adcon2 03d4 16 xxxxxxx0 2 b7 b6 b5 b4 b3 b2 b1 b0 a-d conversion method select bit 0 : without sample and hold 1 : with sample and hold bit symbol bit name function r w note: if the a-d control register is rewritten during a-d conversion, the conversion result is indeterminate. nothing is assigned. these bits can neither be set nor reset. when read, their content is ?? (ja 03 um60) a-d register i symbol address when reset adi(i=0 to 7) 03c0 16 to 03cf 16 indeterminate eight low-order bits of a-d conversion result function r w (b15) b7 b7 b0 b0 (b8) ?during 10-bit mode two high-order bits of a-d conversion result nothing is assigned. these bits can neither be set nor reset. when read, their content is ?? ?during 8-bit mode when read, the content is indeterminate smp reserved bit always set to ? 000
1-110 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change a-d converter 2.24.1 one-shot mode in one-shot mode, the pin selected using the analog input pin select bit is used for one-shot a-d con- version.table 1.32 shows the specifications of one-shot mode. figure 1.100 shows the a-d control register in one-shot mode. figure 1.100: a-d conversion register in one-shot mode table 1.32: one-shot mode speci?cation item speci?cation function the pin selected by the analog input pin select bit is used for one a-d conversion start condition writing 1 to a-d conversion start ?ag stop condition ?end of a-d conversion (a-d conversion start ?ag changes to 0, except when external trigger is selected) ?writing 0 to a-d conversion start ?ag interrupt request generation timing end of a-d conversion input pin one of an0 to an7, as selected reading of result of a-d converter read a-d register corresponding to selected pin a-d control register 0 (note 1) symbol address when reset adcon0 03d6 16 00000xxx 2 b7 b6 b5 b4 b3 b2 b1 b0 analog input pin select bit bit symbol bit name function ch1 ch2 a-d operation mode select bit 0 md0 md1 trigger select bit 0 : software trigger 1 : ad trg trigger trg adst a-d conversion start flag 0 : a-d conversion disabled 1 : a-d conversion started frequency select bit 0 0: f ad /4 is selected 1: f ad /2 is selected cks0 w r 0 0 a-d control register 1 (note) symbol address when reset adcon1 03d7 16 00 16 bit name function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 a-d sweep pin select bit scan0 scan1 md2 bits 8/10-bit mode select bit 0 : 8-bit mode 1 : 10-bit mode vcut vref connect bit a-d operation mode select bit 1 0 : any mode other than repeat sweep mode 1 1 : vref connected w r invalid in one-shot mode 0 0 0 0 : an 0 is selected 0 0 1 : an 1 is selected 0 1 0 : an 2 is selected 0 1 1 : an 3 is selected 1 0 0 : an 4 is selected 1 0 1 : an 5 is selected 1 1 0 : an 6 is selected 1 1 1 : an 7 is selected (note 2) b2 b1 b0 0 0 : one-shot mode (note 2) b4 b3 ch0 1 note 1: if the a-d control register is rewritten during a-d conversion, the conversion result is indeterminate. note 2: when changing a-d operation mode, set analog input pin again. frequency select bit1 0 : f ad /2 or f ad /4 is selected 1 : f ad is selected cks1 note: if the a-d control register is rewritten during a-d conversion, the conversion result is indeterminate. reserved bit always set to "0" 0 0
1-111 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change a-d converter 2.24.2 repeat mode in repeat mode, the pin selected using the analog input pin select bit is used for repeated a-d conver- sion. table 1.33 shows the specifications of repeat mode. figure 1.101 shows the a-d control register in repeat mode. figure 1.101: a-d conversion register in repeat mode table 1.33: repeat sweep mode 0 speci?cations item speci?cation function the pin selected by the analog input pin select bit is used for repeated a-d conversion star condition writing 1 to a-d conversion start ?ag stop condition writing 0 to a-d conversion start ?ag interrupt request generation timing none generated input pin one of an0 to an7, as selected reading of result of a-d converter read a-d register corresponding to selected pin a-d control register 0 (note 1) symbol address when reset adcon0 03d6 16 00000xxx 2 b7 b6 b5 b4 b3 b2 b1 b0 analog input pin select bit ch0 bit symbol bit name function ch1 ch2 a-d operation mode select bit 0 md0 md1 trigger select bit 0 : software trigger 1 : ad trg trigger trg adst a-d conversion start flag 0 : a-d conversion disabled 1 : a-d conversion started frequency select bit 0 0 : f ad /4 is selected 1 : f ad /2 is selected cks0 w r a-d control register 1 (note) symbol address when reset adcon1 03d7 16 00 16 bit name function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 a-d sweep pin select bit scan0 scan1 md2 bits 8/10-bit mode select bit 0 : 8-bit mode 1 : 10-bit mode vcut vref connect bit a-d operation mode select bit 1 1 : vref connected w r 01 invalid in repeat mode 0 0 0 0 : an 0 is selected 0 0 1 : an 1 is selected 0 1 0 : an 2 is selected 0 1 1 : an 3 is selected 1 0 0 : an 4 is selected 1 0 1 : an 5 is selected 1 1 0 : an 6 is selected 1 1 1 : an 7 is selected (note 2) b2 b1 b0 0 1 : repeat mode (note 2) b4 b3 1 note 1: if the a-d control register is rewritten during a-d conversion, the conversion result is indeterminate. note 2: when changing a-d operation mode, set analog input pin again. frequency select bit 1 0 : f ad /2 or f ad /4 is selected 1 : f ad is selected cks1 0 : any mode other than repeat sweep mode 1 note: if the a-d control register is rewritten during a-d conversion, the conversion result is indeterminate. reserved bit always set to "0" 0 0
1-112 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change a-d converter 2.24.3 single sweep mode in single sweep mode, the pins selected using the a-d sweep pin select bit are used for one-by-one a-d conversion. table 1.34 shows the specifications of single sweep mode. figure 1.102 shows the a-d control register in single sweep mode. figure 1.102: a-d conversion register in single sweep mode table 1.34: single sweep mode speci?cation item speci?cation function the pins selected by the a-d sweep pin select bit are used for one-by-one a-d conversion start condition writing 1 to a-d converter start ?ag stop condition ?end of a-d conversion (a-d conversion start ?ag changes to 0, except when external trigger is selected) ?writing 0 to a-d conversion start ?ag interrupt request generation timing end of a-d conversion input pin an0 and an1 (2 pins), an0 to an3 (4 pins), an0 to an5 (6 pins), or an0 to an7 (8 pins) reading of result of a-d converter read a-d register corresponding to selected pin a-d control register 0 (note) symbol address when reset adcon0 03d6 16 00000xxx 2 b7 b6 b5 b4 b3 b2 b1 b0 analog input pin select bit ch0 bit symbol bit name function ch1 ch2 a-d operation mode select bit 0 1 0 : single sweep mode md0 md1 trigger select bit 0 : software trigger 1 : ad trg trigger trg adst a-d conversion start flag 0 : a-d conversion disabled 1 : a-d conversion started frequency select bit 0 0 : f ad /4 is selected 1 : f ad /2 is selected cks0 w r a-d control register 1 (note) symbol address when reset adcon1 03d7 16 00 16 bit name function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 a-d sweep pin select bit scan0 scan1 md2 bits 8/10-bit mode select bit 0 : 8-bit mode 1 : 10-bit mode vcut vref connect bit 0 : any mode other than repeat sweep mode 1 a-d operation mode select bit 1 1 : vref connected w r 1 0 invalid in single sweep mode 0 note : if the a-d control register is rewritten during a-d conversion, the conversion result is indeterminate. b4 b3 when single sweep and repeat sweep mode 0 are selected 0 0 : an 0 , an 1 (2 pins) 0 1 : an 0 to an 3 (4 pins) 1 0 : an 0 to an 5 (6 pins) 1 1 : an 0 to an 7 (8 pins) b1 b0 1 note: if the a-d control register is rewritten during a-d conversion, the conversion result is indeterminate. frequency select bit 1 0 : f ad /2 or f ad /4 is selected 1 : f ad is selected cks1 reserved bit always set to "0" 0 0
1-113 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change a-d converter 2.24.4 repeat sweep mode 0 in repeat sweep mode 0, the pins selected using the a-d sweep pin select bit are used for repeat sweep a-d conversion. table 1.35 shows the specifications of repeat sweep mode 0. figure 1.103 shows the a-d control register in repeat sweep mode 0. figure 1.103: a-d conversion register in repeat sweep mode 0 table 1.35: repeat sweep mode 0 speci?cations item speci?cation function the pins selected by the a-d sweep pin select bit are used for repeat sweep a-d conversion start condition writing 1 to a-d conversion start ?ag stop condition writing 0 to a-d conversion start ?ag interrupt request generation timing none generated input pin an0 and an1 (2 pins), an0 to an3 (4 pins), an0 to an5 (6 pins), or an0 to an7 (8 pins) reading of result of a-d converter read a-d register corresponding to selected pin (at any time) a-d control register 0 (note) symbol address when reset adcon0 03d6 16 00000xxx 2 b7 b6 b5 b4 b3 b2 b1 b0 analog input pin select bit ch0 bit symbol bit name function ch1 ch2 a-d operation mode select bit 0 1 1 : repeat sweep mode 0 md0 md1 trigger select bit 0 : software trigger 1 : ad trg trigger trg adst a-d conversion start flag 0 : a-d conversion disabled 1 : a-d conversion started frequency select bit 0 0 : f ad /4 is selected 1 : f ad /2 is selected cks0 w r a-d control register 1 (note) symbol address when reset adcon1 03d7 16 00 16 bit name function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 a-d sweep pin select bit scan0 scan1 md2 bits 8/10-bit mode select bit 0 : 8-bit mode 1 : 10-bit mode vcut vref connect bit 0 : any mode other than repeat sweep mode 1 a-d operation mode select bit 1 1 : vref connected w r 1 1 invalid in repeat sweep mode 0 0 note: if the a-d control register is rewritten during a-d conversion, the conversion result is indeterminate. b4 b3 when single sweep and repeat sweep mode 0 are selected 0 0 : an 0 , an 1 (2 pins) 0 1 : an 0 to an 3 (4 pins) 1 0 : an 0 to an 5 (6 pins) 1 1 : an 0 to an 7 (8 pins) b1 b0 1 note: if the a-d control register is rewritten during a-d conversion, the conversion result is indeterminate. frequency select bit 1 0 : f ad /2 or f ad /4 is selected 1 : f ad is selected cks1 reserved bit always set to "0" 0 0
1-114 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change a-d converter 2.24.5 repeat sweep mode 1 in repeat sweep mode 1, all pins are used for a-d conversion with emphasis on the pin or pins select- ed using the a-d sweep pin select bit. table 1.36 shows the specifications of repeat sweep mode 1. figure 1.104 show the a-d control in repeat sweep mode 1. table 1.36: repeat sweep mode 1 speci?cation figure 1.104: a-d conversion register in repeat sweep mode 1 item speci?cation function all pins perform repeat sweep a-d conversion, with emphasis on the pin or pins selected by the a-d sweep pin select bit example: an0 selected an0 an1 an0 an2 an0 an3, etc. start condition writing 1 to a-d conversion start ?ag stop condition writing 0 to a-d conversion start ?ag interrupt request generation timing none generated input pin an0 (1 pin), an0 and an1 (2 pins), an0 to an2 (3 pins), an0 to an3 (4 pins) reading of result of a-d converter read a-d register corresponding to selected pin (at any time) a-d control register 0 (note) symbol address when reset adcon0 03d6 16 00000xxx 2 b7 b6 b5 b4 b3 b2 b1 b0 analog input pin select bit ch0 bit symbol bit name function ch1 ch2 a-d operation mode select bit 0 1 1 : repeat sweep mode 1 md0 md1 trigger select bit 0 : software trigger 1 : ad trg trigger trg adst a-d conversion start flag 0 : a-d conversion disabled 1 : a-d conversion started frequency select bit 0 0 : f ad /4 is selected 1 : f ad /2 is selected cks0 w r a-d control register 1 (note) symbol address when reset adcon1 03d7 16 00 16 bit name function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 a-d sweep pin select bit scan0 scan1 md2 bits 8/10-bit mode select bit 0 : 8-bit mode 1 : 10-bit mode vcut vref connect bit 1 : repeat sweep mode 1 a-d operation mode select bit 1 1 : vref connected w r 1 1 invalid in repeat sweep mode 1 1 note: if the a-d control register is rewritten during a-d conversion, the conversion result is indeterminate. b4 b3 when repeat sweep mode 1 is selected 0 0 : an 0 (1 pin) 0 1 : an 0 , an 1 (2 pins) 1 0 : an 0 to an 2 (3 pins) 1 1 : an 0 to an 3 (4 pins) b1 b0 1 note: if the a-d control register is rewritten during a-d conversion, the conversion result is indeterminate. frequency select bit 1 0 : f ad /2 or f ad /4 is selected 1 : f ad is selected cks1 0 0 reserved bit always set to "0 "
1-115 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change a-d converter 2.24.6 sample and hold sample and hold is selected by setting bit 0 of the a-d control register 2 (address 03d4 16 ) to 1. when sample and hold is selected, the rate of conversion of each pin increases. as a result, a 28 f ad cycle is achieved with 8-bit resolution and 33 f ad with 10-bit resolution. sample and hold can be selected in all modes. however, in all modes, be sure to specify before starting a-d conversion whether sample and hold is to be used.
1-116 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change crc calculation circuit 2.25 crc calculation circuit the cyclic redundancy check (crc) calculation circuit detects an error in data blocks. the microcomputer uses a generator polynomial of crc_ccitt (x16 + x12 + x5 + 1) to generate crc code. the crc code is a 16-bit code generated for a block of a given data length in multiples of 8 bits. the crc code is set in a crc data register each time one byte of data is transferred to a crc input register after writing an initial value into the crc data register. generation of crc code for one byte of data is completed in two machine cycles. figure 1.105 shows the block diagram of the crc circuit. figure 1.106 shows the crc-related registers. figure 1.105: block diagram of crc circuit figure 1.106: crc-related registers aaaaaa eight low-order bits aaaaaa eight high-order bits data bus high-order bits data bus low-order bits aaaaaaaaaa aaaaaaaaaa aaaaaa aaaaaa crc data register (16) crc input register (8) aaaaaaaaaa aaaaaaaaaa crc code generating circuit x 16 + x 12 + x 5 + 1 (addresses 03bd 16 , 03bc 16 ) (address 03be 16 ) symbol address when reset crcd 03bd 16 , 03bc 16 indeterminate b7 b0 b7 b0 (b15) (b8) crc data register w r crc calculation result output register function values that can be set 0000 16 to ffff 16 symbo address when reset crcin 03be 16 indeterminate b7 b0 crc input register w r data input register function values that can be set 00 16 to ff 16 aa a aa aa a a
1-117 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change programmable i/o ports 2.26 programmable i/o ports there are 63 programmable i/o ports: p0 to p3, p6 to p8 (excluding p85), and p10. each port can be set independently for input or output using the direction register. a pull-up resistance for each block of 4 ports can be set. p85 is an input-only port and has no built-in pull-up resistance. figure 1.107, figure 1.108 and figure 1.109 show the programmable i/o ports. each pin functions as a programmable i/o port and as the i/o for the built-in peripheral devices. to use the pins as the inputs for the built-in peripheral devices, set the direction register of each pin to input mode. when the pins are used as the outputs for the built-in peripheral devices, they function as outputs regardless of the contents of the direction registers. unused i/o pins can be terminated as shown in figure 1.114 and table 1.37 . 2.26.1 direction registers figure 1.110 shows the direction registers. these registers are used to choose the direction of the programmable i/o ports. each bit in these reg- isters corresponds one for one to each i/o pin. note: there is no direction register bit for p85. 2.26.2 port registers figure 1.111 shows the port registers. these registers are used to write and read data for input and output to and from an external device. a port register consists of a port latch to hold output data and a circuit to read the status of a pin. each bit in port registers corresponds one for one to each i/o pin. 2.26.3 pull-up control registers figure 1.112 shows the pull-up control registers.the pull-up control register can be set to apply a pull- up resistance to each block of 4 ports. when ports are set to have a pull-up resistance, the pull-up resistance is connected only when the direction register is set for input. 2.26.4 high drive capacity registers figure 1.113 shows the port 2 and pwm drive capacity register. port 2 can be configured to drive an led by increasing the drive strength of the corresponding bits n-channel transistor. each timer out- put (ta0out~ta4out) can be configured for high-drive capability by increasing the drive strength of the corresponding bits.
1-118 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change programmable i/o ports figure 1.107: programmable i/o ports (1) p3 0 to p3 6 data bus direction register pull-up selection port latch input to respective peripheral functions p0 0 to p0 7 p1 0 to p1 7 p62, p66, p71, p73,p75, p77, p81, p82, p84, p87 data bus pull-up selection port latch direction register data bus pull-up selection output ? input to respective peripheral functions direction register port latch drive capacity control register p70, p72, p74, p76, p80 p2 0 to p2 7 data bus direction register pull-up selection port latch drive capacity control register
1-119 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change programmable i/o ports figure 1.108: programmable i/o ports (2) p10 0 to p10 7 data bus pull-up selection analog input direction register port latch p3 7 p6 3 , p6 7 p8 6 data bus pull-up selection ? output direction register port latch data bus pull-up selection output ? input to respective peripheral functions direction register port latch p6 0, p6 1, p6 4 , p6 5 p8 5 data bus nmi interrupt input
1-120 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change programmable i/o ports figure 1.109: programmable i/o ports (3) figure 1.110: direction register byte input cnvss input reset input byte cnvss reset note: do not apply a voltage higher than vcc to each port port pi direction register symbol address when reset pdi (i = 0 to 3,6,7,10) 03e2 16 , 03e3 16 , 03e6 16 , 03e7 16 , 00 16 03ee 16, 03ef 16 , 03f6 16 bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 pdi_0 port pi 0 direction register pdi_1 port pi 1 direction register pdi_2 port pi 2 direction register pdi_3 port pi 3 direction register pdi_4 port pi 4 direction register pdi_5 port pi 5 direction register pdi_6 port pi 6 direction register pdi_7 port pi 7 direction register 0 : input mode (functions as an input port) 1 : output mode (functions as an output port) (i = 0 to 3,6,7,10) port p8 direction register symbol address when reset pd8 03f2 16 00x00000 2 bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 pd8_0 port p8 0 direction register pd8_1 port p8 1 direction register pd8_2 port p8 2 direction register pd8_3 port p8 3 direction register pd8_4 port p8 4 direction register nothing is assigned. this bit can either be set nor reset. when read, its content is indeterminate. pd8_6 port p8 6 direction register pd8_7 port p8 7 direction register 0 : input mode (functions as an input port) 1 : output mode (functions as an output port) 0 : input mode (functions as an input port) 1 : output mode (functions as an output port)
1-121 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change programmable i/o ports figure 1.111: port register figure 1.112: pull-up control register port pi register symbol address when reset pi (i = 0 to 3,6,7,10) 03e0 16 , 03e1 16 , 03e4 16 , 03e5 16 indeterminate 03ec 16 , 03ed 16 , 03f4 16 indeterminate bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 pi_0 port pi 0 register pi_1 port pi 1 register pi_2 port pi 2 register pi_3 port pi 3 register pi_4 port pi 4 register pi_5 port pi 5 register pi_6 port pi 6 register pi_7 port pi 7 register data is input and output to and from each pin by reading and writing to and from each corresponding bit 0 : l level data 1 : h level data (i = 0 to 3,6,7,10) port p8 register symbol address when reset p8 03f0 16 indeterminate bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 p8_0 port p8 0 register p8_1 port p8 1 register p8_2 port p8 2 register p8_3 port p8 3 register p8_4 port p8 4 register p8_5 port p8 5 register p8_6 port p8 6 register p8_7 port p8 7 register data is input and output to and from each pin by reading and writing to and from each corresponding bit (except for p8 5 ) 0 : l level data 1 : h level data pull-up control register 0 symbol address when reset pur0 03fc 16 00 16 bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 pu00 p0 0 to p0 3 pull-up pu01 p0 4 to p0 7 pull-up pu02 p1 0 to p1 3 pull-up pu03 p1 4 to p1 7 pull-up pu04 p2 0 to p2 3 pull-up pu05 p2 4 to p2 7 pull-up pu06 p3 0 to p3 3 pull-up pu07 p3 4 to p3 7 pull-up the corresponding port is pulled high with a pull-up resistor 0 : not pulled high 1 : pulled high pull-up control register 1 symbol address when reset pur1 03fd 16 00 16 bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 pu10 p6 0 to p6 3 pull-up pu11 p6 4 to p6 7 pull-up pu12 p7 0 to p7 3 pull-up pu13 p7 4 to p7 7 pull-up pu14 p8 0 to p8 3 pull-up pu15 p8 4, p8 6, p8 7 pull-up pu16 p10 0 to p10 3 pull-up pu17 p10 4 to p10 7 pull-up the corresponding port is pulled high with a pull-up resistor 0 : not pulled high 1 : pulled high
1-122 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change programmable i/o ports figure 1.113: port 2 and timer a output drive capacity registers port 2 drive capacity register symbol address when reset p2dr 03fa 16 00 16 bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 p2dr0 p2 0 led drive capacity p2dr1 p2 1 led drive capacity p2dr2 p2 2 led drive capacity p2dr3 p2 3 led drive capacity p2dr4 p2 4 led drive capacity p2dr5 p2 5 led drive capacity p2dr6 p2 6 led drive capacity p2dr7 p2 7 led drive capacity the n-channel high-drive capacity is activated for the corresponding bit. 0 : normal drive 1 : n-channel high drive timer a output drive capacity register symbol address when reset tadr 03fb 16 00 16 bit name function bit symbol w r b7 b6 b5 b4 b3 b2 b1 b0 tadr0 ta0out drive capacity tadr1 ta1out drive capacity tadr2 ta2out drive capacity tadr3 ta3out drive capacity tadr4 ta4out drive capacity high-drive capacity is activated for the corresponding taiout pin. 0 : normal drive 1 : high drive nothing is assigned. these bits can neither be set nor reset. when read, their content is 0. _ _
1-123 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change programmable i/o ports figure 1.114: example connection unused pins table 1.37: example connection of unused pins in single-chip mode pin name connection ports p0 to p3, p6 to p8, p10 (excluding p85) after setting for input mode, connect every pin to vss or vcc via a resistor; or after setting for output mode, leave these pins open xout open nmi connect via resistor to vcc (pull-up) avcc connect to vcc avss, vref, byte connect to vss usb d+, usb d- open extcap connect to vcc (when dc-dc converter is disabled) connect to vss via cap (when dc-dc converter is enabled and using the attach function) sof open attach open port p0 to p3, p6-p8, p10 (except p8 5 ) (input mode) (input mode) (output mode) usb d+ usb d- microcomputer av cc extcap (note 1) v cc x out sof attach open byte av ss v ref v ss open nmi open open open open note: this is an example when the dc-dc converter is disabled
1-124 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change usage precautions 3.0 usage 3.1 usage precautions 3.1.1 a-d converter ? write to each bit (except bit 6) of a-d control register 0, to each bit of a-d control register 1, and to bit 0 of a-d control register 2 when a-d conversion is stopped (before a trigger occurs). in particular, when the vref connection bit is changed from 0 to 1, start a-d conversion after an elapse of 1 s or longer. ? when changing a-d operation mode, select analog input pin again. ? using one-shot mode or single sweep mode read the corresponding a-d register after confirming the a-d conversion is finished. (it is known by a-d con- version interrupt request bit.) ? using repeat mode, repeat sweep mode 0 or repeat sweep mode 1 use the undivided main clock as the internal cpu clock. 3.1.2 built-in prom version ? all built-in prom versions high voltage is required to program to the built-in prom. be careful not to apply excessive voltage. be espe- cially careful during power-on. ? one time prom version one time prom versions shipped in blank, of which built-in proms are programmed by users, are also pro- vided. for these microcomputers, a programming test and screening are not performed in the assembly pro- cess and the following processes. to improve their reliability after programming, we recommend to program and test as flow shown in figure 11 5 before use. wiring for the vpp pin of the one-time prom version should be as follows (vpp pin is also used as the cnvss pin): ? make the length of wiring between the vpp pin and vss pin or vcc pin the shortest possible. ? when the wiring length has to be longer, connect an approximately 5k ohm resistor in series from the vpp pin to the vss pin or vcc pin with the shortest possible wiring. this is because the vpp pin is the power source input pin for the built-in prom. when programming in the built-in prom, the impedance of the vpp pin is low to allow the electric current for wiring flow into the prom. because of this, noise can enter easily. if noise enters the vpp pin, abnormal instruction codes or data are read from the built-in prom which may cause a program runaway. 3.1.3 dedicated input pins if a dedicated input pin is connected to a power supply that is different than the supply that vcc is con- nected to, a resistor (approximately 1k ohm) should be added between that input pin and the power supply it is connected to, otherwise, if the dedicated input pin voltage is higher than vcc, latch up could occur.
1-125 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change usage precautions 3.1.4 dmac when the dma enable bit (bit 3 of dm0con and dm1con) is set to 1, the dmac is in an active state. the dma request bit (bit 2 of dm0con and dm1con) is set to 1 when a request for dma transfer occurs, regardless of the state of the dma enable bit. if the dmac is active when the request bit becomes 1, the data transfer begins immediately. the request bit is cleared to 0 when the transfer begins. it is also possible for the dma request bit to get set to a 1 due to the dma request cause select bits being changed. therefore, the dma request bit should be cleared (0) after changing the dma request cause select bits. to best judge the state of the dmac, the dma enable bit should be read instead of the dma request bit. 3.1.5 interrupts ? reading address 00000 16 ? when a maskable interrupts occurs, the cpu reads the interrupt information (the interrupt number and in- terrupt request level) in the interrupt sequence. the interrupt request bit of the corresponding interrupt written in address 00000 16 is then set to 0. reading address 00000 16 by software sets enabled highest priority interrupt source request bit to 0. though the interrupt is generated, the interrupt routine may not be executed. do not read address 00000 16 by software. ? setting the stack pointer ? the value of the stack pointer is initialized to 00000 16 immediately after reset. accepting an interrupt before setting a value in the stack pointer may cause program runaway. be sure to set a value in the stack pointer before accepting an interrupt. ? when using the nmi interrupt, initialize the stack pointer at the beginning of a program. concerning the first instruction immediately after reset, generating any interrupts including the nmi interrupt is prohibited. ? setting interrupts ? changing the interrupt priority level select bit (ilvl) and clearing the interrupt request bit (ir) in the in- terrupt control registers (icr) while the interrupt enable flag (i-flag) is 1, may result in unintended op- erations, such as brk and other interrupts being generated. it is recommended that the interrupts be disabled by clearing the i-flag before setting ilvl or clearing the ir bit. to prevent the i-flag from being set before the icr is rewritten due to the effects of the instruction queue, instructions that equal a minimum of 2 cycles should be inserted between writing to the icr and setting the i-flag (2-nops, i mov, i pop, etc.) ? the nmi interrupt ? as for the nmi interrupt pin, an interrupt cannot be prohibited. connect it to the vcc pin if unused. ? do not get into stop mode or wait mode with the nmi pin set to 0. 3.1.6 noise to reduce the possibility of noise problems: ? connect a bypass capacitor (approximately 0.1 uf) across the vss pin and the vcc pin with the short- est possible wiring ? use circuit traces with a larger diameter than other signal traces for vss and vcc. 3.1.7 stop mode and wait mode ? when returning from stop mode by hardware reset, reset pin must be set to l level until main clock oscillation is stabilized. ? when entering either wait or stop mode, you must first enable any interrupts you want to cancel the wait or stop. also, make sure to disable any interrupts that you dont want to cancel the wait or stop. if only hardware reset or nmi interrupts are desired to cancel wait or stop, all other interrupt priority levels should be set to 0.
1-126 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change usage precautions 3.1.8 timer a (timer mode) ? reading the timer ai register while a count is in progress allows reading, with arbitrary timing, the value of the counter. reading the timer ai register with the reload timing gets ffff 16 . reading the timer ai register after setting a value in the timer ai register with a count halted but before the counter starts counting gets a proper value. 3.1.9 timer a (event counter mode) ? reading the timer ai register while a count is in progress allows reading, with arbitrary timing, the value of the counter. reading the timer ai register with the reload timing gets ffff 16 by underflow or 0000 16 by overflow. reading the timer ai register after setting a value in the timer ai register with a count halted but before the counter starts counting gets a proper value. ? when counting is stopped in free-run type, set the timer again. ? when using free-run type, the timers register contents may be unknown when counting starts. set the timer value immediately after counting has started. 3.1.10 timer a (pulse width modulation mode) ? the timer ai interrupt request bit becomes 1 if setting operation mode of the timer in compliance with any of the following procedures: ? selecting pwm mode after reset. ? changing operation mode from timer mode to pwm mode. ? changing operation mode from event counter mode to pwm mode. therefore, to use timer ai interrupt (interrupt request bit), set timer ai interrupt request bit to 0 after the above listed changes have been made. ? setting the count start flag to 0 while pwm pulses are being output causes the counter to stop counting. if the taiout pin is outputting an h level in this instance, the output level goes to l, and the timer ai interrupt request bit goes to 1. if the taiout pin is outputting an l level in this instance, the level does not change, and the timer ai interrupt request bit does not become 1. 3.1.11 timer b (timer mode) ? reading the timer bi register while a count is in progress allows reading, with arbitrary timing, the value of the counter. reading the timer bi register with the reload timing gets ffff 16 . reading the timer bi register after setting a value in the timer bi register with a count halted but before the counter starts counting gets a proper value. 3.1.12 uart2 when using uart2 in clock asynchronous serial i/o mode (uart), use the internal clock only, oth- erwise, one of the following may occur: ? the interrupt may not be issued at the end of the data transmission when the hardware transfers the data from the transmit buffer to the transmit register. ? data may be corrupted when the hardware transfers data fro the transmit buffer register to the transmit reg- ister. this only applies to uart2 asynchronous serial i/o mode and does not apply to uart0 or uart1. 3.1.13 usb usb sfr refers to registers from 0x0300 to 0x033c. all these registers are physically inside the usb block and are affected by the usb reset. also, these registers can only be accessed by 8-bit mode. usb related registers 0x00c, 0x03db-0x3df are not inside the usb block and are not affected by a usb reset and can be accessed by 8 or 16 bits.
1-127 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change usage precautions figure 1.115: programming and test ?ow for one-time prom (otp) version programming with prom programmer screening (note) (leave at 150?c for 40 hours) verify test prom programmer function check in target device note: never expose to 150?c exceeding 100 hours.
1-128 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change electrical 4.0 speci?cations 4.1 electrical note 1: when writing to eprom, cnvss rated value is -0.3 to 13 volts table 1.39: recommended operating conditions note: the total output current is the sum of all the currents ?owing through all the applicable ports. the total average current is an average value measured over 100 ms. the total peak current is the peak value of all the currents. table 1.38: absolute maximum ratings only, not operating conditions symbol parameter condition rated value unit v cc supply voltage v cc =av cc -0.3 to 6.5 v av cc analog supply voltage v cc =av cc -0.3 to 6.5 v v i input voltage port0, port1, port2, port3, port6, port7, port8, port10, r eset ,v ref , x in -0.3 to vcc+0.3 v v i input voltage cnv ss -0.3 to 6.5 (note 1) v v o output voltage port0, port1, port2, port3, port6, port7, port8 (except p85), port10, r eset ,v ref ,x in -0.3 to vcc+0.3 v p d power dissipation ta=25 c 760 mw t opr operating ambient temperature 0 to 70 c t stg storage temperature -65 to 150 c symbol parameter standard unit min typ max v cc supply voltage 4.1 5.0 5.25 v av cc analog supply voltage vcc v v ss supply voltage 0v a vss analog supply voltage 0 v v ih high input voltage port 0, port1, port2, port3, port6, port7, port8, port10, reset, v ref ,x in , cnv ss 0.8vcc vcc v v il low input voltage port0, port1, port2, port3, port6, port7, port8, port10, reset, v ref ,x in , cnv ss 0 0.2vcc v ioh (peak) high peak output current port0, port1, port3, port6, p71, p73, p75, p77, p81 to p87, port10 -10 ma p20 to p27, p70, p72, p74, p76, p80 -20 ma ioh (avg.) high avg output current port0, port1, port3, port6, p71, p73, p75, p77, p81 to p87, port10 -5 ma p20 to p27, p70, p72, p74, p76, p80 -10 ma s ioh(peak) high peak output current p2, p3, p6, p7, p8 0 ~p8 2 -80 ma p0, p1, p8 3 ~p8 7 , p10 -80 ma s ioh (avg.) high avg output current p2, p3, p6, p7, p8 0 ~p8 2 -40 ma p0, p1, p8 3 ~p8 7 , p10 -40 ma iol (peak) low peak output current port0, port1, port3, port6, p71, p73, p75, p77, p81 to p87, port10 10 ma p20 to p27, p70, p72, p74, p76, p80 20 ma iol (avg.) low avg output current port0, port1, port3, port6, p71, p73, p75, p77, p81 to p87, port10 5ma p20 to p27, p70, p72, p74, p76, p80 10 ma s iol (peak) low peak output current p2, p3, p6, p7, p8 0 ~p8 2 80 ma p0, p1, p8 3 ~p8 7 , p10 80 ma s iol (avg. low avg output current p2, p3, p6, p7, p8 0 ~p8 2 40 ma p0, p1, p8 3 ~p8 7 , p10 40 ma f(xin) main clock input oscillation frequency 1 12 mhz
1-129 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change electrical note 1 only high drive when timer a is enabled and drive registers set for high drive mode. table 1.40: electrical characteristics (vcc=4.1~5.25v, vss=0v, ta= 0 c~ 70 c, f(xin) = 12mhz symbol parameter measuring condition standard unit min typ max v oh high output voltage port0, port1, port2, port3, port6, port71, p73,p75,p77,port8 (except p85), port10 i oh = -5ma 3.0 v v oh high output voltage port 70,p72,p74,p76,p80 i oh = -10ma 3.0 v v oh high output voltage port0, port1, port2, port3, port6, port71, p73,p75,p77,port8 (except p85), port10 i oh = -200 m a 4.7 v v oh high output voltage high-drive mode port 2 i oh = -10ma 3.0 v oh high output voltage xout high power i oh = -1ma 3.0 v low power i oh = -0.5ma 3.0 v v ol low output voltage port0, port1, port2, port3, port6, port71, p73,p75,p77,port8 (except p85), port10 i ol = 5ma 2.0 v v ol low output voltage high-drive mode port 2 i ol = 10ma 2.0 v v ol low output voltage port 70,p72,p74,p76,p80 note 1 i ol = 10ma 2.0 v v ol low output voltage port0, port1, port2, port3, port6, port71, p73,p75,p77,port8 (except p85), port10 i ol = 200 m a 0.45 v v ol low output voltage xout high power i oh = 1ma 2.0 v low power i oh = 0.5ma 2.0 v v t +-v t - hysteresis ta 0in to ta 4in, int 0 to int 1, ad trg , cts 0, cts 1, clk 0, clk 1, ta 2out to ta 4out, nmi , ki 0 to ki 15 0.2 0.8 v v t +-v t - hysteresis reset 0.2 1.8 v iih high input current port0, port1, port2, port3, port6, port7,port8, port10, r eset , cnvss v i = 5v 5.0 m a iil low input current port0, port1, port2, port3, port6, port7, port8, port10, r eset , cnvss v i = 0v -5.0 m a r pullup pull-up resistance port0, port1, port2, port3, port6, port7, port8, port10 v i = 0v 30 50 167 k w rx in feedback resistance, xin 1.0 m w v ram ram retention voltage when clock is stopped 2.0 v icc power supply current output pins open, other pins tied to vss icc run with usb on (mask) 80 ma icc run with usb on (otp) 95 ma icc run with usb off 50 ma ta=25 c clock stopped 1 m a ta=70 c clock stopped 20 m a ta=25 c wait mode with internal clocks on 8ma ta=25 c wait mode with internal clocks off 4ma
1-130 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timing note: see fig. 122 for recommended con?guration. 4.2 timing timing requirements referenced to vcc = 4.1~5.25v, vss=0v, ta= 0 c~70 c unless otherwise speci?ed . table 1.41: usb electrical characteristics (vcc=4.1~5.25v, vss=0v, ta= 0 c ~ 70 c , f(xin) = 12mhz) symbol parameter measuring condition standard unit min typ max v oh d+, d- i=18.3 ma, rx=33 w , vxcap =3.0 v 2.2 v v ol d+, d- i=18.3 ma, rx=33 w , vxcap =3.0 v 0.8 v isusp suspend current usb suspend mode, internal clock stopped 175 m a xcap dc-dc converter voltage dc-dc converter output voltage on xcap pin 3.0 3.3 3.6 v table 1.42: a-d conversion characteristics (vcc, avcc = 4.1~5.25v, vss=0v, ta= 0 c~ 70 c, f(xin) = 12mhz) symbol parameter measuring condition standard unit min typ max - resolution v ref = vcc 10 bits - absolute accuracy sample and hold function not available v ref = vcc = 5v 3 lsb sample and hold function available (10bit) v ref = vcc = 5v 3 lsb sample and hold function available (8bit) v ref = vcc = 5v 2 lsb r ladder resistance v ref = vcc 10 40 k w gonave conversion time (10bit) 2.75 m s t conv conversion time (8bit) 2.34 m s t samp sampling time 0.25 m s v ref reference voltage 2 v v ia analog input voltage (min. operating frequency =x) 0 v ref v f ad a-d clock frequency 1 12 mhz table 1.43: external clock input symbol parameter standard unit min max tc external clock input cycle time 83.3 ns tw(h) external clock input high pulse width 33 ns tw(l) external clock input low pulse width 33 ns tr external clock rise time 15 ns tf external clock fall time 15 ns
1-131 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timing table 1.44: timer a input (counter input in event counter mode) symbol parameter standard unit min max tc( ta )tai in input cycle time 100 ns tw( ta h )tai in input high pulse width 40 ns tw( ta l )tai in input low pulse width 40 ns table 1.45: timer a input (gating input in timer mode) symbol parameter standard unit min max tc( ta )tai in input cycle time 400 ns tw( ta h )tai in input high pulse width 200 ns tw( ta l )tai in input low pulse width 200 ns table 1.46: timer a input (external trigger input in one-shot timer mode) symbol parameter standard unit min max tc( ta )tai in input cycle time 200 ns tw( ta h )tai in input high pulse width 100 ns tw( ta l )tai in input low pulse width 100 ns table 1.47: timer a input (external trigger input in pulse width modulation mode) symbol parameter standard unit min max tw( ta h )tai in input high pulse width 100 ns tw( ta l )tai in input low pulse width 100 ns table 1.48: timer a input (up/down input in event counter mode) symbol parameter standard unit min max tc( up )tai out input cycle time 2000 ns tw( uph )tai out input high pulse width 1000 ns tw( upl )tai out input low pulse width 1000 ns tsu( up - tin )tai out input setup time 400 ns th( tin - up )tai out input hold time 400 ns table 1.49: a-d trigger input symbol parameter standard unit min max tc(ad) ad trg input cycle time (triggerable minimum) 1000 ns tw(adl) ad trg input low pulse width 125 ns
1-132 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timing table 1.51: external interrupt inti inputs table 1.50: serial i/o symbol parameter standard unit min max tc( ck ) clki input cycle time 200 ns tw( ckh ) clki input high pulse width 100 ns tw( ckl ) clki input low pulse width 100 ns td( c - q ) txdi output delay time 80 ns th( c - q ) txdi hold time 0 ns tsu( d - c ) rxdi input setup time 30 ns th( c - d ) rxdi input hold time 90 ns symbol parameter standard unit min max tw( inh ) int i input high pulse width 250 ns tw( inl ) int i input low pulse width 250 ns
1-133 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change timing diagrams- peripheral/interrupt 4.3 timing diagrams- peripheral/interrupt figure 1.116: peripheral / interrupt timing diagram tai in input tai out input during event counter mode t c(ta) t w(tah) t w(tal) t c(up) t w(uph) t w(upl) t h(t in ?p) t su(up? in ) tai in input (when count on falling edge is selected) tai in input (when count on rising edge is selected) tai out input (up/down input) t su(d?) clki txdi rxdi t c(ad) t w(adl) t c(ck) t w(ckh) t w(ckl) t w(inl) t w(inh) t d(c?) t h(c?) t h(c?) inti input ad trg input
1-134 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change frequency synthesizer interface and dc-dc converter 5.0 applications 5.1 frequency synthesizer interface and dc-dc converter this section presents the recommended method of setting up and using the frequency synthesizer that generates the 48mhz clock needed by the usb fcu and the dc-dc converter that provides pow- er to the d+/d- drivers 5.1.1 reset of usb related registers figure 1.117: sfr reset venn diagram the special function registers (sfrs) that govern the operation of the frequency synthesizer, dc-dc converter and usb fcu are affected by one or more reset events. the addresses of the special func- tion registers (sfrs) that are affected by hardware reset, usb reset, or both are shown in figure 1.117. all resettable sfrs, including sfrs and other registers internal to the usb fcu, are affected by a hardware reset, which occurs when the reset pin is brought low or an undefined opcode is fetched. see section 2.4 for a complete listing of sfrs and their reset values. only registers internal to the usb fcu are reset when a usb reset sent by the host/hub is detected. these usb registers are reset to their default values except for bit 5 of usbis2 (usb reset interrupt status flag), which is set to a 1. usb fcu registers are registers from address 300 16 to 33c 16 and all other registers within the usb fcu, many of which the mcu does not have direct access to (e.g. fifo address pointers). the usb fifo registers are empty after usb reset because the fifo ad- dress pointers are reset. however, the physical contents of the fifos are not set to all 1s or all 0s. other sfrs such as usbc, fsc, and cm0, cm1 are not affected by a usb reset. hardware reset usb reset sfr registers: 0004 16 to 005f 16 , 378 16 to 3ff 16 000c (usbc), 3dc 16 (fsc) sfr registers: 300 16 to 33c 16 (usb fcu registers)
1-135 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change frequency synthesizer interface and dc-dc converter 5.1.2 set up of frequency synthesizer and dc-dc converter figure 1.118: pll, dc-dc converter and usb functional block diagram a functional block diagram of the usb system on the m30240 which shows how the control signals affect operation is given in figure 1.118 5.1.2.1 set up after hardware reset a hardware reset occurs when either the reset pin is brought low for more than 2 m s or an invalid opcode is fetched by the cpu. the frequency synthesizer (pll) and dc-dc converter should be set up as follows in the hardware reset routine (see figure 1.119), ? power up the m30240 and other components on the peripheral device for less than 100 ma opera- tion. the current limit only applies for bus powered devices. ? configure the pll for 48mhz f(vco) operation. ? enable the pll by setting fse (bit 0 of the frequency synthesizer control register (fsc)) to a 1, then wait for 2 ms. ? check the lock status bit (ls, bit 7 of fsc). ? if the bit is a 1, go on. ? if the bit is a 0, wait 0.1 ms longer and then re-check the bit. ? enable the dc-dc converter in high current mode by setting usbc4 (bit 4 of the usb control reg- ister (usbc)) to a 1 and keeping usbc3 (bit 3 of usbc) a 0. high current mode should always be used during normal usb operation. low current mode should only be used during a usb sus- pend. ? wait (c + 1)ms (where c equals the external capacitance connected to the ext cap pin in m f) for the voltage on ext cap to reach a steady state voltage of approximately 3.3v. (since the d+ pullup is connected to the ext cap pin, the upstream hub will detect that the peripheral device has been plugged in once the voltage on d+ reaches approximately 2.0 v.) ? example: a 2.2 m f capacitor connected to ext cap requires 3.2 ms for the voltage on ext cap to be stable. 33 w 33 w d+ d- usb fcu 2.2 m f 0.1 m f ext cap frequency synthesizer f(xin) fse ls 1.5k w usb transceiver dc-dc converter usbc3 usbc4 usbc7 usbc7 usbc5 usbclk (48mhz) enable lock enable enable (enable) (enable) enable current mode
1-136 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change frequency synthesizer interface and dc-dc converter ? enable the usb clock by setting usbc5 (bit 5 of usbc) to a 1. (if the usb clock and fcu are enabled before the voltage on ext cap is stable, a phantom usb reset may be detected, or the ac- tual usb reset may not be detected.) ? wait at least 4 cycles of f , then enable the usb fcu by setting usbc7 (bit 7 of usbc) to a 1. ? enable other blocks as necessary. figure 1.119: pll and dc-dc converter set up timing after hardware reset 5.1.2.1.1 precautions after software reset a software reset occurs after writing a 1 to bit 3 of the processor mode register 0 (address 0004 16 ). during software reset, the contents of the internal ram are preserved as well as all usb, dc-dc converter, and pll registers. if the pll is used as the system clock source, it is important to note that after a software reset oc- curs, any writes to the frequency synthesizer register will cause it to freeze. this can cause erratic device be- havior. in order to avoid this, it is recommended that the following procedure be used: ? prior to software reset, switch device clock source from fsyn to f(xin). please see the frequency synthe- sizer specification for more details. ? after software reset using firmware, evaluate the condition of the synthesizer control register (fsc register, address 03dc 16 , bit 0). this bit is not effected by a software reset and can check to see if the pll is still enabled. if so, any setup routine that involves writing to the pll registers should not be called. at this point, the clock source can be changed back to fsyn. 5.1.2.2 set up after usb reset signaling detected a usb reset is detected by the usb fcu when an se0 is present on d+/d- for at least 2.5 m s. de- tection of a usb reset results in bit 5 of usb interrupt status register 2 (usbis2) being set to a 1 and the registers within the usb fcu being reset to their default values. register usbc and the pll registers are not affected by a usb reset. a usb function interrupt request is also generated when the usb reset is detected. no modifications to the frequency synthesizer or dc-dc converter configuration should be made in the usb function interrupt routine. however, all usb fcu registers (addresses 300 16 to 33c 16 ) must be reconfigured to their pre-enumeration state. reset fse ls usbc4 usbc5 usbc7 wait 2 m s wait (c+1) m s enable pll enable dc-dc converter enable usb clock enable usb fcu wait at least 4 cycles of f
1-137 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change frequency synthesizer interface and dc-dc converter 5.1.2.3 set up after usb suspend detected a usb suspend occurs if the usb fcu does not detect any bus activity on d+/d- for at least 3 ms. detection of a suspend results in bit 7 of usbis2 and bit 0 of usbpm (suspend) being set to a 1. this causes bit 3 of suspic to be set to a 1. bit 7 of usbis2 then needs to be cleared by writing a 1 to the bit in order to allow a future suspend event. the configuration of the frequency synthesizer and dc-dc converter should be changed as follows in the usb suspend interrupt routine (if the device is bus powered): ? change the dc-dc converter from high current mode to low current mode by setting usbc3 (bit 3 of the usbc) to a 1 ? disable the usb clock by setting usbc5 (bit 5 of usbc) to a 0. once the usb clock is disabled, registers internal to the usb fcu should not be written to. this includes all usb sfrs from address 0300 16 to 033c 16 . it does not include usbc or fsc. ? perform other tasks to reduce total current to below 500 m a. ? disable the pll by setting fse (bit 0 of fsc) to a 0. ? make sure the i-flag is set to 1. ? stop the system clock by setting cm10 (bit 0 of cm1) to a 1. make sure to first enable writing to the system clock control register by setting prco (bit 0 of prcr) to 1. also, make sure to enable the usb resume interrupt (rsmic register) and clear or execute any pending interrupts prior to stop- ping the clock so the mcu can wake up once resume signaling is detected. if the clock is stopped using an interrupt routine, make sure to set the priority of the resume interrupt (rsmic) higher than the current interrupt. ? note that no action may be necessary if the device is self powered. 5.1.2.4 set up after usb resume signaling detected a resume occurs when the usb fcu is in the suspend state and detects a non-idle signaling on d+/ d-. detection of a resume results in bit 6 of usbis2 and bit 1 of usbpm (resume) being set to a 1. this causes bit 3 of rsmic to also be set to 1. if the mcu was in the stop state prior to the detection of the resume, the usb resume interrupt request will cause the mcu to wake up from the stop state. bit 6 of usbis2 needs to be cleared (by writing a 1 to the bit) in order to allow a future resume event. see section 2.9 stop mode for details on waking up from the stop state. the configuration of the frequency synthesizer and dc-dc converter should be changed as follows in the usb resume interrupt routine (if the device is bus powered): ? re-enable the pll for 48mhz f(vco) by setting fse (bit 0 of the fsc) to a 1, then wait for 2 ms. ? wait for 2 ms. ? check the lock status bit (ls, bit 7 of fsc). ? if the bit is a 1, continue. ? if the bit is a 0, wait 0.1 ms longer and then re-check the bit. ? enable the usb clock by setting usbc5 (bit 5 of usbc) to a 1. ? wait for a minimum of 4 cycles. ? change the dc-dc converter from low current mode to high current mode by setting usbc3 (bit 3 of the usbc) to a 0. ? enable other blocks as necessary. registers internal to the usb fcu should not be written to until the usb clock is re-enabled. this in- cludes all usb sfrs from address 0300 16 to 033c 16 . it does not include usbc or fsc. note that the configuration changes described above may not need to be made if the mcu was not placed in a suspend state as described in section 5.1.2.3 set up after usb suspend detected.
1-138 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change attach/detach function 5.1.2.5 pll lock bit the pll lock bit is used to indicate when the pll is first locked. accordingly, after the pll is enabled and it has been given 2.0 ms to stabilize, the lock bit status should be checked. once the lock bit is high, the usb check should be enabled. after this stage, the lock bit is no longer valid and should not be monitored, unless the pll is re-enabled. 5.2 attach/detach function the attach/detach function can be used to attach or detach a usb function from the host without dis- connecting the cable. when attaching a usb function, the connect registers should be set to 3 hex at the same time on or before the dc-dc converter is enabled. similarly, when detaching the connect register, it should be set to 1 hex when powering down the dc-dc converter. if you do not set the connect (address 1fh) to high, the system will default to its normal mode. note: if the d+ is connected to extcap, this mode will not work. d+ is connected to extcap through a 1.5 k resistor in compliance with the usb specification. usb suspend/resume function hardware connections are shown below attach is connected to d+ through 1.5 k resistor. attach [p8 3 ] d+ (pin 9 m30240) attach/detach mode disabled extcap d+ (pin 9 m30240) 1.5 k 1.5 k
1-139 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change low pass filter network 5.3 low pass filter network all passive components should be in close proximity to pin 78 (lpf), capacitors should be x7r di- electric or better. the recommended values are listed in table 1.52 . see figure 1.120 for schematic of the lpf. figure 1.120: lpf filter schematic analog v ss and analog v cc , pins 77 and 80 should have isolated connections to the digital v ss and v cc ground planes. figure 1.121 illustrates the power supply isolation. figure 1.121: power supply table 1.52: recommended values r 1000 w 10% c2 = 680 pf 10% c1 = 0.1 m f 10% r c1 c2 pin 78 (lpf) pin 77 a vss digital v cc (on card) digital v ss analog v ss (pin 77) analog v cc (pin 80) c c decoupling capacitors ferrite beads
1-140 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change usb transceiver 5.4 usb transceiver when using the on-chip voltage converter to supply the necessary 3.3v to the driver circuit, a capac- itor network must be connected between ext. cap (pin 6) and v ss (pin 13). two capacitors are re- quired as shown in figure 1.122. the high frequency 0.1 m f capacitor should be an x7r type or better. the low frequency decoupling capacitor of 2.2 m f should be of tantalum di-electric or better. the start- up time for this value of the capacitor is 3.2 ms, approximately (1ms/ m f ) + 1 ms. after enabling the on-chip voltage converter, a certain amount of time must pass before a wait or stop clock instruction is executed. the amount of time is given by (c+1) ms, when c is the value in m f of the external capacitance connected to the ext. cap pin. for example, if the external capacitance is 2.2 m f , at least 3.2 ms must elapse from the time that the on-chip voltage converter is enabled until a wait instruction or stop command (cm10 = 1) is executed. in order to meet the impedance matching requirements of the usb specification, a 33 w resistor must be added to usb d+ (pin 9) and to usb d- (pin 10). in addition, capacitors connected between usb d+ and usb d- or usb d+/d- and vss may need to be added for rise/fall time matching and edge control. these capacitors should be placed after the 33 w resistors. their configuration and values will depend on the pcs layout. the placement of external components is illustrated in figure 1.122. figure 1.122: con?guration of external usb components 33 w 33 w + _ d+ d- xcv_vm_in xcv_vp_in xcv_rxd xcv_vp_out xcv_suspend xcv_vm_out xcv_txen_n transceiver usb_vp_out usb_txen_n usb_vm_out usb_suspend usb_rxd usb_vp_in usb_vm_in usb block voltage converter 2.2 m f 0.1 m f 10% ext cap 22 pf = = 22 pf 10% 33 pf (note) note: capacitor values and con?guration may depend on pcb layout.
1-141 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change programming notes 5.5 programming notes 5.5.1 accessing usb in/out csr registers do not use read-modify-write instruction on these registers because they contain control and status bits that can be changed by both hardware and software. there is a possibility that using a read-mod- ify-write instruction might cause incorrect data to be written back to these registers. see table 1.53 for a list of bits that may have incorrect data written to them and the value you should write back in order to prevent this from occurring. the endpoint 1-4 in csrs (epiics, i = 1-4) have a bit in_pkt_rdy (bit 0) that is set to a 1 by the firmware after a packet of data is loaded to the respective endpoints fifo. this signifies that a packet is ready for transmission. if the firmware wants to send a null packet to the host, it can simply write a 1 to the in_pkt_rdy bit without loading data to the fifo. this bit is cleared by the hardware. if the firmware manipulates (writes) the in csr for a purpose other than to signify to the hardware that a data packet is ready for transmission (for instance, set/reset iso bit, set/reset send_stall bit), it must make sure that a 0 is written back to the in_pkt_rdy bit. failure to do so could cause improp- er operation of the device. writing a 0 to the in_pkt_rdy bit has no effect on its state. the endpoint 1-4 out csrs (epiics, i = 1-4) have a bit out_pkt_rdy (bit 0) that is set to a 1 by the hardware after a packet of data is received from the host to the respective endpoints fifo. this signifies that a packet is ready for download. this bit is cleared by the firmware by writing a 0 to it after the data packet is unloaded from the fifo. if the firmware manipulates (writes) the out csr for a purpose other than to signify to the hardware that a data packet has been unloaded (for instance, set/reset iso bit, set/reset send_stall bit), it must make sure that a 1 is written back to the out_pkt_rdy bit. failure to do so could cause improper operation. writing a 1 to the out_pkt_rdy bit has no effect on its state. table 1.53: bits that might have incorrect data register name bit name value to write for no change ep0cs in_pkt_rdy (b1) 0 data_end (b3) 0 force_stall (b4) 1 epxics (x = 1-4) in_pkt_rdy (b0) 0 under_run (b1) 1 epxocs (x = 1-4) out_pkt_rdy (b0) 1 over_run (b1) 1 force_stall (b4) 1 data-err (b5) 1
1-142 mitsubishi microcomputers m30240 group single-chip 16-bit cmos microcomputer preliminary specifications rev. e specifications in this manual are tentative and subject to change programming notes below is an example of how to set/reset the iso bit of the in csr register (for initializing the respective endpoint as an isochronous endpoint): 5.5.2 usb consecutive set address the usb specification states that the host can send a set_address request for the following cas- es: 1. during enumeration when the device is in default state. (the host assigns a non-zero address.) 2. when the device is in the address state. (the host can re-assign a new address.) the device handles case #1 (when the device is in the default state) and case #2 (when the device is in the address state) differently. the following is a segment of code to illustrate the program flow to properly deal with these cases. note: wvalue_lo = assigned address from the host in set-address request. [r1l] = [epiics].b or.b #08h, r1l ;set iso bit = 1, write 1 back to under_run bit and.b #0feh, r1l ;write 0 back to in_pkt_rdy bit [epiics].b = [r1l] [r1l] = [epiics].b or.b #02, r1l ;write 1 back to under_run bit and.b #0f6h, r1l ;reset iso bit = 0, write 0 back to in_pkt_rdy bit [epiics].b= [r1l] default_state: if [usba].b ==0 [usba.].b = wvalue _ lo ;if the device is in default state, update address before status completion r1l = [ep0cs].b ;usb endpoint 0 csr or.b #48h, r1l ;set serviced_out_pkt_rdy & data_end [ep0cs].b = r1l wait for the completion of the jmp addr_end else addr_state r1l [ep0cs].b ;usb endpoint 0 csr or.b #48h, r1l ;set serviced_out_pkt_rdy & data_end [ep0cs].b = r1l wait for the completion of the [usba].b= wvalue_lo ;if the device is in address state, update address before status completion addr_end endif end of the set_address routine


▲Up To Search▲   

 
Price & Availability of M30240S7-XXXFP

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X